Build instructions in readme.md are complicated and don't work -- please provide a VS project template. #143

Closed
opened 2026-01-29 16:32:18 +00:00 by claunia · 12 comments
Owner

Originally created by @BrainSlugs83 on GitHub (Apr 13, 2018).

Originally assigned to: @robertmuehsig on GitHub.

Using VS 2017 15.6.4, I created a new .NET Core MVC app.

I followed build instructions up to the ElectronNET.CLI nuget package part (which is super ambiguous).

I added the DotNetCliToolReference to my .csproj like so (it didn't say to remove the other ones, so I left them alone):

<Project Sdk="Microsoft.NET.Sdk.Web">

  <PropertyGroup>
    <TargetFramework>netcoreapp2.0</TargetFramework>
  </PropertyGroup>

  <ItemGroup>
    <PackageReference Include="ElectronNET.API" Version="0.0.9" />
    <PackageReference Include="Microsoft.AspNetCore.All" Version="2.0.6" />
  </ItemGroup>

  <ItemGroup>
    <DotNetCliToolReference Include="Microsoft.VisualStudio.Web.CodeGeneration.Tools" Version="2.0.3" />
    <DotNetCliToolReference Include="ElectronNET.CLI" Version="0.0.9" />
  </ItemGroup>
  
</Project>

dotnet restore did not add the CLI package that I just added.

and manually calling Install-Package ElectronNET.CLI -Version 0.0.9 fails because it's not compatible with this project type:
Install-Package : Package 'ElectronNET.CLI 0.0.9' has a package type 'DotnetCliTool' that is not supported by project 'ElectronTest'.

(Also requiring folks to hand edit a .csproj is kind of wacky -- please just provide a visual studio template.)

Trying to run the project, it opens a chrome web browser up to the site (not an electron window).

Further details, program.cs:

    public class Program
    {
        public static void Main(string[] args)
        {
            BuildWebHost(args).Run();
        }

        public static IWebHost BuildWebHost(string[] args)
        {
            return WebHost.CreateDefaultBuilder(args)
                .UseElectron(args)
                .UseStartup<Startup>()
                .Build();
        }
    }

startup.cs:

    public class Startup
    {
        public Startup(IConfiguration configuration)
        {
            Configuration = configuration;
        }

        public IConfiguration Configuration { get; }

        // This method gets called by the runtime. Use this method to add services to the
        // container.
        public void ConfigureServices(IServiceCollection services)
        {
            services.AddMvc();
        }

        // This method gets called by the runtime. Use this method to configure the HTTP
        // request pipeline.
        public void Configure(IApplicationBuilder app, IHostingEnvironment env)
        {
            if (env.IsDevelopment())
            {
                app.UseBrowserLink();
                app.UseDeveloperExceptionPage();
            }
            else
            {
                app.UseExceptionHandler("/Home/Error");
            }

            app.UseStaticFiles();

            app.UseMvc(routes =>
            {
                routes.MapRoute(
                    name: "default",
                    template: "{controller=Home}/{action=Index}/{id?}");
            });

            // Open the Electron-Window here
            Task.Run(async () => await Electron.WindowManager.CreateWindowAsync());
        }
    }
Originally created by @BrainSlugs83 on GitHub (Apr 13, 2018). Originally assigned to: @robertmuehsig on GitHub. Using VS 2017 15.6.4, I created a new .NET Core MVC app. I followed build instructions up to the `ElectronNET.CLI` nuget package part (which is super ambiguous). I added the `DotNetCliToolReference` to my .csproj like so (it didn't say to remove the other ones, so I left them alone): ``` <Project Sdk="Microsoft.NET.Sdk.Web"> <PropertyGroup> <TargetFramework>netcoreapp2.0</TargetFramework> </PropertyGroup> <ItemGroup> <PackageReference Include="ElectronNET.API" Version="0.0.9" /> <PackageReference Include="Microsoft.AspNetCore.All" Version="2.0.6" /> </ItemGroup> <ItemGroup> <DotNetCliToolReference Include="Microsoft.VisualStudio.Web.CodeGeneration.Tools" Version="2.0.3" /> <DotNetCliToolReference Include="ElectronNET.CLI" Version="0.0.9" /> </ItemGroup> </Project> ``` `dotnet restore` did not add the CLI package that I just added. and manually calling `Install-Package ElectronNET.CLI -Version 0.0.9` fails because it's not compatible with this project type: `Install-Package : Package 'ElectronNET.CLI 0.0.9' has a package type 'DotnetCliTool' that is not supported by project 'ElectronTest'.` (Also requiring folks to hand edit a .csproj is kind of wacky -- please just provide a visual studio template.) Trying to run the project, it opens a chrome web browser up to the site (not an electron window). Further details, `program.cs`: ``` public class Program { public static void Main(string[] args) { BuildWebHost(args).Run(); } public static IWebHost BuildWebHost(string[] args) { return WebHost.CreateDefaultBuilder(args) .UseElectron(args) .UseStartup<Startup>() .Build(); } } ``` `startup.cs`: ``` public class Startup { public Startup(IConfiguration configuration) { Configuration = configuration; } public IConfiguration Configuration { get; } // This method gets called by the runtime. Use this method to add services to the // container. public void ConfigureServices(IServiceCollection services) { services.AddMvc(); } // This method gets called by the runtime. Use this method to configure the HTTP // request pipeline. public void Configure(IApplicationBuilder app, IHostingEnvironment env) { if (env.IsDevelopment()) { app.UseBrowserLink(); app.UseDeveloperExceptionPage(); } else { app.UseExceptionHandler("/Home/Error"); } app.UseStaticFiles(); app.UseMvc(routes => { routes.MapRoute( name: "default", template: "{controller=Home}/{action=Index}/{id?}"); }); // Open the Electron-Window here Task.Run(async () => await Electron.WindowManager.CreateWindowAsync()); } } ```
Author
Owner

@BrainSlugs83 commented on GitHub (Apr 13, 2018):

Additionally, I tried:

npm install electron-packager --global
dotnet new mvc
dotnet restore
dotnet electronize init

which fails with No executable found matching command "dotnet-electronize".

@BrainSlugs83 commented on GitHub (Apr 13, 2018): Additionally, I tried: ``` npm install electron-packager --global dotnet new mvc dotnet restore dotnet electronize init ``` which fails with `No executable found matching command "dotnet-electronize"`.
Author
Owner

@BrainSlugs83 commented on GitHub (Apr 13, 2018):

Finally, I also tried:

git clone https://github.com/ElectronNET/electron.net-api-demos.git
cd electron.net-api-demos
cd ElectronNET-API-Demos
dotnet restore
dotnet electronize start

which fails on the last command dotnet electronize start with:

d:\projects.git\electron.net-api-demos\ElectronNET-API-Demos>dotnet electronize start
Start Electron Desktop Application...
Microsoft Windows [Version 10.0.16299.309]
(c) 2017 Microsoft Corporation. All rights reserved.
d:\projects.git\electron.net-api-demos\ElectronNET-API-Demos>dotnet publish -r win-x64 --output "d:\projects.git\electron.net-api-demos\ElectronNET-API-Demos\obj\Host\bin"
Microsoft (R) Build Engine version 15.6.82.30579 for .NET Core
Copyright (C) Microsoft Corporation. All rights reserved.
  Restore completed in 103.62 ms for d:\projects.git\electron.net-api-demos\ElectronNET-API-Demos\ElectronNET-API-Demos.csproj.
  Restore completed in 126.12 ms for d:\projects.git\electron.net-api-demos\ElectronNET-API-Demos\ElectronNET-API-Demos.csproj.
  Restore completed in 71.22 ms for d:\projects.git\electron.net-api-demos\ElectronNET-API-Demos\ElectronNET-API-Demos.csproj.
  ElectronNET-API-Demos -> d:\projects.git\electron.net-api-demos\ElectronNET-API-Demos\bin\Debug\netcoreapp2.0\win-x64\ElectronNET-API-Demos.dll
  ElectronNET-API-Demos -> d:\projects.git\electron.net-api-demos\ElectronNET-API-Demos\obj\Host\bin\
d:\projects.git\electron.net-api-demos\ElectronNET-API-Demos>
Skip npm install, because node_modules directory exists in: d:\projects.git\electron.net-api-demos\ElectronNET-API-Demos\obj\Host\node_modules
Invoke electron.cmd - in dir: d:\projects.git\electron.net-api-demos\ElectronNET-API-Demos\obj\Host\node_modules\.bin
Microsoft Windows [Version 10.0.16299.309]
(c) 2017 Microsoft Corporation. All rights reserved.
d:\projects.git\electron.net-api-demos\ElectronNET-API-Demos\obj\Host\node_modules\.bin>electron.cmd "..\..\main.js"
'electron.cmd' is not recognized as an internal or external command,
operable program or batch file.
d:\projects.git\electron.net-api-demos\ElectronNET-API-Demos\obj\Host\node_modules\.bin>
@BrainSlugs83 commented on GitHub (Apr 13, 2018): Finally, I also tried: ``` git clone https://github.com/ElectronNET/electron.net-api-demos.git cd electron.net-api-demos cd ElectronNET-API-Demos dotnet restore dotnet electronize start ``` which fails on the last command `dotnet electronize start` with: ``` d:\projects.git\electron.net-api-demos\ElectronNET-API-Demos>dotnet electronize start Start Electron Desktop Application... Microsoft Windows [Version 10.0.16299.309] (c) 2017 Microsoft Corporation. All rights reserved. d:\projects.git\electron.net-api-demos\ElectronNET-API-Demos>dotnet publish -r win-x64 --output "d:\projects.git\electron.net-api-demos\ElectronNET-API-Demos\obj\Host\bin" Microsoft (R) Build Engine version 15.6.82.30579 for .NET Core Copyright (C) Microsoft Corporation. All rights reserved. Restore completed in 103.62 ms for d:\projects.git\electron.net-api-demos\ElectronNET-API-Demos\ElectronNET-API-Demos.csproj. Restore completed in 126.12 ms for d:\projects.git\electron.net-api-demos\ElectronNET-API-Demos\ElectronNET-API-Demos.csproj. Restore completed in 71.22 ms for d:\projects.git\electron.net-api-demos\ElectronNET-API-Demos\ElectronNET-API-Demos.csproj. ElectronNET-API-Demos -> d:\projects.git\electron.net-api-demos\ElectronNET-API-Demos\bin\Debug\netcoreapp2.0\win-x64\ElectronNET-API-Demos.dll ElectronNET-API-Demos -> d:\projects.git\electron.net-api-demos\ElectronNET-API-Demos\obj\Host\bin\ d:\projects.git\electron.net-api-demos\ElectronNET-API-Demos> Skip npm install, because node_modules directory exists in: d:\projects.git\electron.net-api-demos\ElectronNET-API-Demos\obj\Host\node_modules Invoke electron.cmd - in dir: d:\projects.git\electron.net-api-demos\ElectronNET-API-Demos\obj\Host\node_modules\.bin Microsoft Windows [Version 10.0.16299.309] (c) 2017 Microsoft Corporation. All rights reserved. d:\projects.git\electron.net-api-demos\ElectronNET-API-Demos\obj\Host\node_modules\.bin>electron.cmd "..\..\main.js" 'electron.cmd' is not recognized as an internal or external command, operable program or batch file. d:\projects.git\electron.net-api-demos\ElectronNET-API-Demos\obj\Host\node_modules\.bin> ```
Author
Owner

@GregorBiswanger commented on GitHub (Apr 14, 2018):

Hi @BrainSlugs83
I don´t know why dotnet restore does not install the CLI.
Do you have installed .NET Core 2.0 or 2.1 Beta etc.?!
@robertmuehsig any idea?

The last comment with the electron.net api demos app have a other problem. The CLI detects a installed electron, but the electron is not installed. Try to execute npm install electron --global and start the samples app again.

@GregorBiswanger commented on GitHub (Apr 14, 2018): Hi @BrainSlugs83 I don´t know why `dotnet restore` does not install the CLI. Do you have installed .NET Core 2.0 or 2.1 Beta etc.?! @robertmuehsig any idea? The last comment with the electron.net api demos app have a other problem. The CLI detects a installed electron, but the electron is not installed. Try to execute `npm install electron --global` and start the samples app again.
Author
Owner

@bravecobra commented on GitHub (Aug 5, 2018):

Same issue here

@bravecobra commented on GitHub (Aug 5, 2018): Same issue here
Author
Owner

@laurensstrydom-WDFC commented on GitHub (Aug 27, 2018):

Fairly easy to reproduce, happens when one includes
ElectronNET.CLI as a PackageReference instead of DotNetCliToolReference.

@bravecobra , @GregorBiswanger , @BrainSlugs83.

@laurensstrydom-WDFC commented on GitHub (Aug 27, 2018): Fairly easy to reproduce, happens when one includes ElectronNET.CLI as a PackageReference instead of DotNetCliToolReference. @bravecobra , @GregorBiswanger , @BrainSlugs83.
Author
Owner

@paillave commented on GitHub (Dec 6, 2018):

I face the same issue, I'm on .net core 2.1
morevover, if I add the following in my csproj:
<ItemGroup> <DotNetCliToolReference Include="ElectronNET.CLI" Version="0.0.10" /> </ItemGroup>
then run dotnet restore
I get the following:

Restoring packages for C:\Users\sroyer\Source\Repos\Etl.Net\src\Paillave.Etl.Debugger\Paillave.Etl.Debugger.csproj...
  Restoring packages for C:\Users\sroyer\Source\Repos\Etl.Net\src\Paillave.Etl.Debugger\Paillave.Etl.Debugger.csproj...
C:\Users\sroyer\Source\Repos\Etl.Net\src\Paillave.Etl.Debugger\Paillave.Etl.Debugger.csproj : error NU1202: Package ElectronNET.CLI 0.0.10 is not compatible with netcoreapp2.1
(.NETCoreApp,Version=v2.1). Package ElectronNET.CLI 0.0.10 supports: netcoreapp2.1 (.NETCoreApp,Version=v2.1) / any
C:\Users\sroyer\Source\Repos\Etl.Net\src\Paillave.Etl.Debugger\Paillave.Etl.Debugger.csproj : error NU1212: Invalid project-package combination for ElectronNET.CLI 0.0.10. DotnetToolReference project style can only contain references of the DotnetTool type
  Restore failed in 180.52 ms for C:\Users\sroyer\Source\Repos\Etl.Net\src\Paillave.Etl.Debugger\Paillave.Etl.Debugger.csproj.
  Generating MSBuild file C:\Users\sroyer\Source\Repos\Etl.Net\src\Paillave.Etl.Debugger\obj\Paillave.Etl.Debugger.csproj.nuget.g.props.
  Restore completed in 2.32 sec for C:\Users\sroyer\Source\Repos\Etl.Net\src\Paillave.Etl.Debugger\Paillave.Etl.Debugger.csproj.
@paillave commented on GitHub (Dec 6, 2018): I face the same issue, I'm on .net core 2.1 morevover, if I add the following in my csproj: `<ItemGroup> <DotNetCliToolReference Include="ElectronNET.CLI" Version="0.0.10" /> </ItemGroup>` then run `dotnet restore` I get the following: ``` Restoring packages for C:\Users\sroyer\Source\Repos\Etl.Net\src\Paillave.Etl.Debugger\Paillave.Etl.Debugger.csproj... Restoring packages for C:\Users\sroyer\Source\Repos\Etl.Net\src\Paillave.Etl.Debugger\Paillave.Etl.Debugger.csproj... C:\Users\sroyer\Source\Repos\Etl.Net\src\Paillave.Etl.Debugger\Paillave.Etl.Debugger.csproj : error NU1202: Package ElectronNET.CLI 0.0.10 is not compatible with netcoreapp2.1 (.NETCoreApp,Version=v2.1). Package ElectronNET.CLI 0.0.10 supports: netcoreapp2.1 (.NETCoreApp,Version=v2.1) / any C:\Users\sroyer\Source\Repos\Etl.Net\src\Paillave.Etl.Debugger\Paillave.Etl.Debugger.csproj : error NU1212: Invalid project-package combination for ElectronNET.CLI 0.0.10. DotnetToolReference project style can only contain references of the DotnetTool type Restore failed in 180.52 ms for C:\Users\sroyer\Source\Repos\Etl.Net\src\Paillave.Etl.Debugger\Paillave.Etl.Debugger.csproj. Generating MSBuild file C:\Users\sroyer\Source\Repos\Etl.Net\src\Paillave.Etl.Debugger\obj\Paillave.Etl.Debugger.csproj.nuget.g.props. Restore completed in 2.32 sec for C:\Users\sroyer\Source\Repos\Etl.Net\src\Paillave.Etl.Debugger\Paillave.Etl.Debugger.csproj. ```
Author
Owner

@paillave commented on GitHub (Dec 6, 2018):

actually, it works when

I face the same issue, I'm on .net core 2.1
morevover, if I add the following in my csproj:
<ItemGroup> <DotNetCliToolReference Include="ElectronNET.CLI" Version="0.0.10" /> </ItemGroup>
then run dotnet restore
I get the following:

Restoring packages for C:\Users\sroyer\Source\Repos\Etl.Net\src\Paillave.Etl.Debugger\Paillave.Etl.Debugger.csproj...
  Restoring packages for C:\Users\sroyer\Source\Repos\Etl.Net\src\Paillave.Etl.Debugger\Paillave.Etl.Debugger.csproj...
C:\Users\sroyer\Source\Repos\Etl.Net\src\Paillave.Etl.Debugger\Paillave.Etl.Debugger.csproj : error NU1202: Package ElectronNET.CLI 0.0.10 is not compatible with netcoreapp2.1
(.NETCoreApp,Version=v2.1). Package ElectronNET.CLI 0.0.10 supports: netcoreapp2.1 (.NETCoreApp,Version=v2.1) / any
C:\Users\sroyer\Source\Repos\Etl.Net\src\Paillave.Etl.Debugger\Paillave.Etl.Debugger.csproj : error NU1212: Invalid project-package combination for ElectronNET.CLI 0.0.10. DotnetToolReference project style can only contain references of the DotnetTool type
  Restore failed in 180.52 ms for C:\Users\sroyer\Source\Repos\Etl.Net\src\Paillave.Etl.Debugger\Paillave.Etl.Debugger.csproj.
  Generating MSBuild file C:\Users\sroyer\Source\Repos\Etl.Net\src\Paillave.Etl.Debugger\obj\Paillave.Etl.Debugger.csproj.nuget.g.props.
  Restore completed in 2.32 sec for C:\Users\sroyer\Source\Repos\Etl.Net\src\Paillave.Etl.Debugger\Paillave.Etl.Debugger.csproj.

actually it works when I call electronize instead of dotnet electronize either the installation is not correctly accepted, either the documentation is not up to date

@paillave commented on GitHub (Dec 6, 2018): actually, it works when > I face the same issue, I'm on .net core 2.1 > morevover, if I add the following in my csproj: > `<ItemGroup> <DotNetCliToolReference Include="ElectronNET.CLI" Version="0.0.10" /> </ItemGroup>` > then run `dotnet restore` > I get the following: > > ``` > Restoring packages for C:\Users\sroyer\Source\Repos\Etl.Net\src\Paillave.Etl.Debugger\Paillave.Etl.Debugger.csproj... > Restoring packages for C:\Users\sroyer\Source\Repos\Etl.Net\src\Paillave.Etl.Debugger\Paillave.Etl.Debugger.csproj... > C:\Users\sroyer\Source\Repos\Etl.Net\src\Paillave.Etl.Debugger\Paillave.Etl.Debugger.csproj : error NU1202: Package ElectronNET.CLI 0.0.10 is not compatible with netcoreapp2.1 > (.NETCoreApp,Version=v2.1). Package ElectronNET.CLI 0.0.10 supports: netcoreapp2.1 (.NETCoreApp,Version=v2.1) / any > C:\Users\sroyer\Source\Repos\Etl.Net\src\Paillave.Etl.Debugger\Paillave.Etl.Debugger.csproj : error NU1212: Invalid project-package combination for ElectronNET.CLI 0.0.10. DotnetToolReference project style can only contain references of the DotnetTool type > Restore failed in 180.52 ms for C:\Users\sroyer\Source\Repos\Etl.Net\src\Paillave.Etl.Debugger\Paillave.Etl.Debugger.csproj. > Generating MSBuild file C:\Users\sroyer\Source\Repos\Etl.Net\src\Paillave.Etl.Debugger\obj\Paillave.Etl.Debugger.csproj.nuget.g.props. > Restore completed in 2.32 sec for C:\Users\sroyer\Source\Repos\Etl.Net\src\Paillave.Etl.Debugger\Paillave.Etl.Debugger.csproj. > ``` actually it works when I call `electronize` instead of `dotnet electronize` either the installation is not correctly accepted, either the documentation is not up to date
Author
Owner

@robertmuehsig commented on GitHub (Dec 7, 2018):

With Version 0.0.10 you need to remove the DotNetCliToolReference in your .csproj and install it as a global tool like this:

dotnet tool install ElectronNET.CLI -g
@robertmuehsig commented on GitHub (Dec 7, 2018): With Version 0.0.10 you need to remove the DotNetCliToolReference in your .csproj and install it as a global tool like this: dotnet tool install ElectronNET.CLI -g
Author
Owner

@paillave commented on GitHub (Dec 8, 2018):

I did this already, as it is instructions that are mentioned and that I followed letter by letter... Still it didn't work: dotnet command doesn't recognize electronize even if it is installed globally like you reminded, and even if it is not in the csproj file like you reminded as well.

@paillave commented on GitHub (Dec 8, 2018): I did this already, as it is instructions that are mentioned and that I followed letter by letter... Still it didn't work: dotnet command doesn't recognize `electronize` even if it is installed globally like you reminded, and even if it is not in the csproj file like you reminded as well.
Author
Owner

@ruohki commented on GitHub (Dec 24, 2018):

same issue on a freshly installed windows / VS2017

edit using 0.0.9 works however

@ruohki commented on GitHub (Dec 24, 2018): same issue on a freshly installed windows / VS2017 edit using 0.0.9 works however
Author
Owner

@robertmuehsig commented on GitHub (Jan 3, 2019):

We updated the readme.

The DotNetCliToolReference is "old" - the new style requires to install it as a global tool:

dotnet tool install ElectronNET.CLI -g

After that you should be able to invoke like this (in the same folder as the .csproj file)

electronize start 

Hope this helps!

@robertmuehsig commented on GitHub (Jan 3, 2019): We updated the readme. The DotNetCliToolReference is "old" - the new style requires to install it as a global tool: dotnet tool install ElectronNET.CLI -g After that you should be able to invoke like this (in the same folder as the .csproj file) electronize start Hope this helps!
Author
Owner

@LukeTOBrien commented on GitHub (Jul 6, 2020):

@robertmuehsig This should be on your main documentation (if you can call a readme main documentation), I just had and same thing and came to this issue after a Google search - Everyone who uses Electron.NET is going to have the same issue

@LukeTOBrien commented on GitHub (Jul 6, 2020): @robertmuehsig This should be on your main documentation (if you can call a readme main documentation), I just had and same thing and came to this issue after a Google search - Everyone who uses Electron.NET is going to have the same issue
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: starred/Electron.NET#143