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

Open
opened 2026-01-29 16:32:16 +00:00 by claunia · 0 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()); } } ```
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: starred/Electron.NET#140