Pass configuration profile to electronize #497

Closed
opened 2026-01-29 16:41:09 +00:00 by claunia · 5 comments
Owner

Originally created by @nazar322 on GitHub (May 19, 2020).

Originally assigned to: @GregorBiswanger on GitHub.

I work on a cross-platform project that supposes to run on both Mac and Windows. To avoid code duplicates I have classes that mostly share the same code but might have platform-specific areas that I distinct from the rest of the code with #if WINDOWS for instance. Then I have created configuration profiles for each Windows and Mac builds that define symbols I need to compile my project for the platform I need.
The problem with electronize is that I cannot pass my configuration profile and therefore, because my code dependent on predefined symbols, dotnet publish fails to build my project.
Please add a command argument to pass the configuration profile to both electronize build and electronize start commands.

Originally created by @nazar322 on GitHub (May 19, 2020). Originally assigned to: @GregorBiswanger on GitHub. <!-- Please search existing feature request to avoid creating duplicates. --> <!-- If you want, you can donate to increase feature request priority (https://donorbox.org/electron-net) --> <!-- Describe the feature you'd like. --> I work on a cross-platform project that supposes to run on both Mac and Windows. To avoid code duplicates I have classes that mostly share the same code but might have platform-specific areas that I distinct from the rest of the code with `#if WINDOWS` for instance. Then I have created configuration profiles for each Windows and Mac builds that define symbols I need to compile my project for the platform I need. The problem with `electronize` is that I cannot pass my configuration profile and therefore, because my code dependent on predefined symbols, `dotnet publish` fails to build my project. Please add a command argument to pass the configuration profile to both `electronize build` and `electronize start` commands.
claunia added the Feature label 2026-01-29 16:41:09 +00:00
Author
Owner

@GregorBiswanger commented on GitHub (May 19, 2020):

Have you tried the following command?
electronize start /args ASPNETCORE_ENVIRONMENT="Development"

@GregorBiswanger commented on GitHub (May 19, 2020): Have you tried the following command? `electronize start /args ASPNETCORE_ENVIRONMENT="Development"`
Author
Owner

@GregorBiswanger commented on GitHub (May 19, 2020):

With .NET Core you can use native methods:
bool isWindows = System.Runtime.InteropServices.RuntimeInformation .IsOSPlatform(OSPlatform.Windows);

@GregorBiswanger commented on GitHub (May 19, 2020): With .NET Core you can use native methods: `bool isWindows = System.Runtime.InteropServices.RuntimeInformation .IsOSPlatform(OSPlatform.Windows);`
Author
Owner

@GregorBiswanger commented on GitHub (May 19, 2020):

I see, we have already the following command:
electronize start /dotnet-configuration development

Works?

@GregorBiswanger commented on GitHub (May 19, 2020): I see, we have already the following command: `electronize start /dotnet-configuration development` Works?
Author
Owner

@nazar322 commented on GitHub (May 20, 2020):

With .NET Core you can use native methods:
bool isWindows = System.Runtime.InteropServices.RuntimeInformation .IsOSPlatform(OSPlatform.Windows);

It's an option to check for the platform in the runtime, but I also have executables embedded as a resource both for Mac and Windows and in order to embed a correct resource I use confitional including in csproj, like in the example below.

<Choose>
	<When Condition="'$(Configuration)' == 'Debug (Windows)' or '$(Configuration)' == 'Release (Windows)'">
	  <ItemGroup>
		<EmbeddedResource Include="ffmpeg.exe.gz" />
	  </ItemGroup>
	</When>
  </Choose>
  <Choose>
	<When Condition="'$(Configuration)' == 'Debug (OSX)' or '$(Configuration)' == 'Release (OSX)'">
	  <ItemGroup>
		<EmbeddedResource Include="ffmpeg.gz" />
	  </ItemGroup>
	</When>
  </Choose>

So I still need to pass the configuration needed.

@nazar322 commented on GitHub (May 20, 2020): > With .NET Core you can use native methods: > `bool isWindows = System.Runtime.InteropServices.RuntimeInformation .IsOSPlatform(OSPlatform.Windows);` It's an option to check for the platform in the runtime, but I also have executables embedded as a resource both for Mac and Windows and in order to embed a correct resource I use confitional including in csproj, like in the example below. ``` <Choose> <When Condition="'$(Configuration)' == 'Debug (Windows)' or '$(Configuration)' == 'Release (Windows)'"> <ItemGroup> <EmbeddedResource Include="ffmpeg.exe.gz" /> </ItemGroup> </When> </Choose> <Choose> <When Condition="'$(Configuration)' == 'Debug (OSX)' or '$(Configuration)' == 'Release (OSX)'"> <ItemGroup> <EmbeddedResource Include="ffmpeg.gz" /> </ItemGroup> </When> </Choose> ``` So I still need to pass the configuration needed.
Author
Owner

@nazar322 commented on GitHub (May 20, 2020):

I see, we have already the following command:
electronize start /dotnet-configuration development

Works?

Unfortunately, it didn't work.
The following dotnet publish command does not contain --configuration argument. It is the same as when not passing /dotnet-configuration argument.
However, when I use the same dotnet publish command electronize start produces but just append --configuration MYCONFIGURATION it builds well.
I also have not found any references to /dotnet-configuration in StartElectronCommand.cs.
By the way, here is my version of Electron.NET CLI
ElectronNET.CLI Version: 8.31.2.0

@nazar322 commented on GitHub (May 20, 2020): > I see, we have already the following command: > `electronize start /dotnet-configuration development` > > Works? Unfortunately, it didn't work. The following `dotnet publish` command does not contain `--configuration` argument. It is the same as when not passing `/dotnet-configuration` argument. However, when I use the same `dotnet publish` command `electronize start` produces but just append `--configuration MYCONFIGURATION` it builds well. I also have not found any references to `/dotnet-configuration` in StartElectronCommand.cs. By the way, here is my version of Electron.NET CLI `ElectronNET.CLI Version: 8.31.2.0`
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: starred/Electron.NET#497