New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Closed
BrainSlugs83 opened this Issue Apr 13, 2018 · 11 comments

Comments

Projects
None yet
7 participants
@BrainSlugs83
Copy link

BrainSlugs83 commented Apr 13, 2018

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());
        }
    }
@BrainSlugs83

This comment has been minimized.

Copy link

BrainSlugs83 commented 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

This comment has been minimized.

Copy link

BrainSlugs83 commented 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>
@GregorBiswanger

This comment has been minimized.

Copy link
Member

GregorBiswanger commented 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.

@bravecobra

This comment has been minimized.

Copy link

bravecobra commented Aug 5, 2018

Same issue here

@laurensstrydom-WDFC

This comment has been minimized.

Copy link

laurensstrydom-WDFC commented Aug 27, 2018

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

@bravecobra , @GregorBiswanger , @BrainSlugs83.

@paillave

This comment has been minimized.

Copy link

paillave commented 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

This comment has been minimized.

Copy link

paillave commented 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

@robertmuehsig

This comment has been minimized.

Copy link
Collaborator

robertmuehsig commented 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
@paillave

This comment has been minimized.

Copy link

paillave commented 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.

@ruohki

This comment has been minimized.

Copy link

ruohki commented Dec 24, 2018

same issue on a freshly installed windows / VS2017

edit using 0.0.9 works however

@robertmuehsig

This comment has been minimized.

Copy link
Collaborator

robertmuehsig commented 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!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment