Skip to content

Update to .NET Core 3.0 #313

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

Merged
merged 16 commits into from
Oct 28, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 1 addition & 2 deletions .travis.yml
Original file line number Diff line number Diff line change
@@ -1,9 +1,8 @@
language: csharp
mono: none
dist: xenial
dotnet: 2.2
dotnet: 3.0
before_script:
- export PATH="$PATH:/home/travis/.dotnet/tools"
- npm install electron-packager --global
script:
- ./buildAll.sh
20 changes: 13 additions & 7 deletions ElectronNET.API/ElectronNET.API.csproj
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<Project Sdk="Microsoft.NET.Sdk">

<PropertyGroup>
<TargetFramework>netcoreapp2.2</TargetFramework>
<TargetFramework>netcoreapp3.0</TargetFramework>
<GeneratePackageOnBuild>true</GeneratePackageOnBuild>
<PackageOutputPath>..\artifacts</PackageOutputPath>
<PackageId>ElectronNET.API</PackageId>
Expand All @@ -17,32 +17,38 @@ This package contains the API to access the "native" electron API.</Description>
<PublishRepositoryUrl>true</PublishRepositoryUrl>
<PackageTags>electron aspnetcore</PackageTags>
<PackageReleaseNotes>Changelog: https://github.com/ElectronNET/Electron.NET/blob/master/Changelog.md</PackageReleaseNotes>
<PackageIconUrl>https://raw.githubusercontent.com/ElectronNET/Electron.NET/master/assets/images/electron.net-logo-square.png</PackageIconUrl>
<Version>1.0.0.0</Version>
<PackageIcon>PackageIcon.png</PackageIcon>
<Version>99.0.0.0</Version>
</PropertyGroup>

<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|AnyCPU'">
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Better replace lines which define DocumentationFile this one big switch with just

<GenerateDocumentationFile>true</GenerateDocumentationFile>

This will have same effect but without need to generate all permutations. But this one change can be made separately from this PR

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Could you point me to a documentation? I just found some links that said that this controls the XML documentation behavior. Those lines are for the NuGet package icon or do I miss something?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I cannot say anything about documentation, since I found that long time ago when lurking around MS projects or people who closely monitor .NET Core development.

Essentially this switch produce XML files in the default location, so instead of duplication configuration and paths everywhere you just include that property in the project file. You can see in the #323 how exactly it simplifies project file.

Here the links which you can find interesting:
https://github.com/dotnet/sdk/blob/b28a8efbfb30d84019351abb3aa9a2b15e008662/src/Tasks/Microsoft.NET.Build.Tasks/targets/Microsoft.NET.Sdk.BeforeCommon.targets#L178

https://stackoverflow.com/questions/47115877/how-to-generate-xml-documentation-for-csproj-with-multiple-targets

<DocumentationFile>bin\Debug\netcoreapp2.0\ElectronNET.API.xml</DocumentationFile>
</PropertyGroup>

<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|AnyCPU'">
<DocumentationFile>bin\Release\netcoreapp2.0\ElectronNET.API.xml</DocumentationFile>
<DocumentationFile>bin\Release\netcoreapp3.0\ElectronNET.API.xml</DocumentationFile>
</PropertyGroup>

<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|AnyCPU'">
<DocumentationFile>bin\Debug\netcoreapp2.0\ElectronNET.API.xml</DocumentationFile>
<DocumentationFile>bin\Debug\netcoreapp3.0\ElectronNET.API.xml</DocumentationFile>
<Optimize>true</Optimize>
</PropertyGroup>

<ItemGroup>
<None Include="PackageIcon.png" Pack="true" PackagePath="\" />
</ItemGroup>

<Target Name="PostBuild" AfterTargets="PostBuildEvent" Condition="'$(OS)' == 'Windows_NT'">
<Exec Command="$(ProjectDir)devCleanup.cmd" IgnoreExitCode="true" />
</Target>
<Target Name="PostBuild" AfterTargets="PostBuildEvent" Condition="'$(OS)' != 'Windows_NT'">
<Exec Command="$(ProjectDir)devCleanup.sh" IgnoreExitCode="true" />
</Target>
<ItemGroup>
<PackageReference Include="Microsoft.AspNetCore.Hosting.Abstractions" Version="2.1.1" />
<PackageReference Include="Microsoft.SourceLink.GitHub" Version="1.0.0-beta2-18618-05">
<FrameworkReference Include="Microsoft.AspNetCore.App" />
</ItemGroup>
<ItemGroup>
<PackageReference Include="Microsoft.SourceLink.GitHub" Version="1.0.0-beta2-19367-01">
<PrivateAssets>all</PrivateAssets>
<IncludeAssets>runtime; build; native; contentfiles; analyzers</IncludeAssets>
</PackageReference>
Expand Down
Binary file added ElectronNET.API/PackageIcon.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
3 changes: 1 addition & 2 deletions ElectronNET.CLI/Commands/AddCommand.cs
Original file line number Diff line number Diff line change
Expand Up @@ -72,9 +72,8 @@ public Task<bool> ExecuteAsync()
ProcessHelper.CmdExecute("npm install", targetFilePath);

// run typescript compiler
string tscPath = Path.Combine(targetFilePath, "node_modules", ".bin");
// ToDo: Not sure if this runs under linux/macos
ProcessHelper.CmdExecute(@"tsc -p ../../", tscPath);
ProcessHelper.CmdExecute(@"npx tsc -p ../../", targetFilePath);

// search .csproj
Console.WriteLine($"Search your .csproj to add configure CopyToPublishDirectory to 'Never'");
Expand Down
24 changes: 3 additions & 21 deletions ElectronNET.CLI/Commands/BuildCommand.cs
Original file line number Diff line number Diff line change
Expand Up @@ -105,21 +105,6 @@ public Task<bool> ExecuteAsync()
Console.WriteLine("Start npm install...");
ProcessHelper.CmdExecute("npm install --production", tempPath);

Console.WriteLine("Start npm install electron-builder...");

if (RuntimeInformation.IsOSPlatform(OSPlatform.Windows))

{
// Works proper on Windows...
ProcessHelper.CmdExecute("npm install electron-builder --global", tempPath);
}
else
{
// ToDo: find another solution or document it proper
// GH Issue https://github.com/electron-userland/electron-prebuilt/issues/48
Console.WriteLine("Electron Builder - make sure you invoke 'sudo npm install electron-builder --global' at " + tempPath + " manually. Sry.");
}

Console.WriteLine("ElectronHostHook handling started...");

string electronhosthookDir = Path.Combine(Directory.GetCurrentDirectory(), "ElectronHostHook");
Expand All @@ -130,13 +115,10 @@ public Task<bool> ExecuteAsync()
DirectoryCopy.Do(electronhosthookDir, hosthookDir, true, new List<string>() { "node_modules" });

Console.WriteLine("Start npm install for hosthooks...");
ProcessHelper.CmdExecute("npm install --production", hosthookDir);
ProcessHelper.CmdExecute("npm install", hosthookDir);

// ToDo: Global TypeScript installation is needed for ElectronHostHook
//string tscPath = Path.Combine(tempPath, "node_modules", ".bin");

// ToDo: Not sure if this runs under linux/macos
ProcessHelper.CmdExecute(@"tsc -p . --sourceMap false", hosthookDir);
ProcessHelper.CmdExecute(@"npx tsc -p . --sourceMap false", hosthookDir);
}

Console.WriteLine("Build Electron Desktop Application...");
Expand Down Expand Up @@ -171,7 +153,7 @@ public Task<bool> ExecuteAsync()
ProcessHelper.CmdExecute($"node build-helper.js", tempPath);

Console.WriteLine($"Package Electron App for Platform {platformInfo.ElectronPackerPlatform}...");
ProcessHelper.CmdExecute($"electron-builder . --config=./bin/electron-builder.json --{platformInfo.ElectronPackerPlatform} --{electronArch} -c.electronVersion=5.0.8 {electronParams}", tempPath);
ProcessHelper.CmdExecute($"npx electron-builder . --config=./bin/electron-builder.json --{platformInfo.ElectronPackerPlatform} --{electronArch} -c.electronVersion=5.0.8 {electronParams}", tempPath);

Console.WriteLine("... done");

Expand Down
5 changes: 2 additions & 3 deletions ElectronNET.CLI/Commands/StartElectronCommand.cs
Original file line number Diff line number Diff line change
Expand Up @@ -76,12 +76,11 @@ public Task<bool> ExecuteAsync()
string hosthookDir = Path.Combine(tempPath, "ElectronHostHook");
DirectoryCopy.Do(electronhosthookDir, hosthookDir, true, new List<string>() { "node_modules" });

Console.WriteLine("Start npm install for hosthooks...");
Console.WriteLine("Start npm install for typescript & hosthooks...");
ProcessHelper.CmdExecute("npm install", hosthookDir);

string tscPath = Path.Combine(tempPath, "node_modules", ".bin");
// ToDo: Not sure if this runs under linux/macos
ProcessHelper.CmdExecute(@"tsc -p ../../ElectronHostHook", tscPath);
ProcessHelper.CmdExecute(@"npx tsc -p ../../ElectronHostHook", tempPath);
}

string path = Path.Combine(tempPath, "node_modules", ".bin");
Expand Down
15 changes: 10 additions & 5 deletions ElectronNET.CLI/ElectronNET.CLI.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -2,14 +2,15 @@

<PropertyGroup>
<OutputType>Exe</OutputType>
<TargetFramework>netcoreapp2.2</TargetFramework>
<TargetFramework>netcoreapp3.0</TargetFramework>
<AssemblyName>electronize</AssemblyName>

<PackageType>DotnetCliTool</PackageType>
<GeneratePackageOnBuild>true</GeneratePackageOnBuild>
<PackageOutputPath>..\artifacts</PackageOutputPath>
<PackageId>ElectronNET.CLI</PackageId>
<Version>1.0.0.0</Version>
<!-- Version 99 is just set for local development stuff to avoid a conflict with "real" packages on NuGet.org -->
<Version>99.0.0.0</Version>
<Authors>Gregor Biswanger, Robert Muehsig</Authors>
<Product>Electron.NET</Product>
<Company />
Expand All @@ -22,7 +23,7 @@ This package contains the dotnet tooling to electronize your application.</Descr
<PublishRepositoryUrl>true</PublishRepositoryUrl>
<PackageTags>electron aspnetcore</PackageTags>
<PackageReleaseNotes>Changelog: https://github.com/ElectronNET/Electron.NET/blob/master/Changelog.md</PackageReleaseNotes>
<PackageIconUrl>https://raw.githubusercontent.com/ElectronNET/Electron.NET/master/assets/images/electron.net-logo-square.png</PackageIconUrl>
<PackageIcon>PackageIcon.png</PackageIcon>
<PackAsTool>true</PackAsTool>
</PropertyGroup>

Expand All @@ -38,7 +39,11 @@ This package contains the dotnet tooling to electronize your application.</Descr
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|AnyCPU'">
<DocumentationFile></DocumentationFile>
</PropertyGroup>


<ItemGroup>
<None Include="PackageIcon.png" Pack="true" PackagePath="\"/>
</ItemGroup>

<ItemGroup>
<EmbeddedResource Include="..\ElectronNET.Host\electron.manifest.json" Link="ElectronHost\electron.manifest.json" />
</ItemGroup>
Expand Down Expand Up @@ -96,7 +101,7 @@ This package contains the dotnet tooling to electronize your application.</Descr
</ItemGroup>

<ItemGroup>
<PackageReference Include="Microsoft.SourceLink.GitHub" Version="1.0.0-beta2-18618-05">
<PackageReference Include="Microsoft.SourceLink.GitHub" Version="1.0.0-beta2-19367-01">
<PrivateAssets>all</PrivateAssets>
<IncludeAssets>runtime; build; native; contentfiles; analyzers</IncludeAssets>
</PackageReference>
Expand Down
Binary file added ElectronNET.CLI/PackageIcon.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
4 changes: 2 additions & 2 deletions ElectronNET.WebApp/Controllers/TrayController.cs
Original file line number Diff line number Diff line change
Expand Up @@ -8,9 +8,9 @@ namespace ElectronNET.WebApp.Controllers
{
public class TrayController : Controller
{
private readonly IHostingEnvironment _env;
private readonly IWebHostEnvironment _env;

public TrayController(IHostingEnvironment env)
public TrayController(IWebHostEnvironment env)
{
_env = env;
}
Expand Down
3 changes: 2 additions & 1 deletion ElectronNET.WebApp/ElectronHostHook/excelCreator.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion ElectronNET.WebApp/ElectronHostHook/excelCreator.js.map

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

3 changes: 2 additions & 1 deletion ElectronNET.WebApp/ElectronHostHook/index.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion ElectronNET.WebApp/ElectronHostHook/index.js.map

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

12 changes: 5 additions & 7 deletions ElectronNET.WebApp/ElectronNET.WebApp.csproj
Original file line number Diff line number Diff line change
@@ -1,8 +1,10 @@
<Project Sdk="Microsoft.NET.Sdk.Web">
<PropertyGroup>
<TargetFramework>netcoreapp2.2</TargetFramework>
<TargetFramework>netcoreapp3.0</TargetFramework>
<AspNetCoreHostingModel>OutOfProcess</AspNetCoreHostingModel>
<AspNetCoreModuleName>AspNetCoreModule</AspNetCoreModuleName>
<RuntimeIdentifiers>win-x64</RuntimeIdentifiers>
<TypeScriptToolsVersion>3.1</TypeScriptToolsVersion>
<TypeScriptToolsVersion>3.6</TypeScriptToolsVersion>
</PropertyGroup>
<ItemGroup>
<Compile Remove="Controllers\ManageWindowsController.cs" />
Expand All @@ -14,11 +16,7 @@
<Folder Include="wwwroot\assets\" />
</ItemGroup>
<ItemGroup>
<PackageReference Include="Microsoft.AspNetCore" Version="2.0.0" />
<PackageReference Include="Microsoft.AspNetCore.Mvc" Version="2.0.0" />
<PackageReference Include="Microsoft.AspNetCore.StaticFiles" Version="2.0.0" />
<PackageReference Include="Microsoft.VisualStudio.Web.BrowserLink" Version="2.0.0" />
<PackageReference Include="Microsoft.VisualStudio.Web.CodeGeneration.Design" Version="2.0.0" />
<PackageReference Include="Microsoft.VisualStudio.Web.CodeGeneration.Design" Version="3.0.0" />
</ItemGroup>
<ItemGroup>
<ProjectReference Include="..\ElectronNET.API\ElectronNET.API.csproj" />
Expand Down
2 changes: 2 additions & 0 deletions ElectronNET.WebApp/Program.cs
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
using ElectronNET.API;
using Microsoft.AspNetCore;
using Microsoft.AspNetCore.Hosting;
using Microsoft.Extensions.Logging;

namespace ElectronNET.WebApp
{
Expand All @@ -14,6 +15,7 @@ public static void Main(string[] args)
public static IWebHost BuildWebHost(string[] args)
{
return WebHost.CreateDefaultBuilder(args)
.ConfigureLogging((hostingContext, logging) => { logging.AddConsole(); })
.UseElectron(args)
.UseStartup<Startup>()
.Build();
Expand Down
17 changes: 7 additions & 10 deletions ElectronNET.WebApp/Startup.cs
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
using Microsoft.Extensions.Configuration;
using Microsoft.Extensions.DependencyInjection;
using Microsoft.Extensions.Logging;
using Microsoft.Extensions.Hosting;

namespace ElectronNET.WebApp
{
Expand All @@ -25,27 +26,23 @@ public void ConfigureServices(IServiceCollection services)
}

// This method gets called by the runtime. Use this method to configure the HTTP request pipeline.
public void Configure(IApplicationBuilder app, IHostingEnvironment env, ILoggerFactory loggerFactory)
public void Configure(IApplicationBuilder app, IWebHostEnvironment env)
{
loggerFactory.AddConsole();

if (env.IsDevelopment())
{
app.UseDeveloperExceptionPage();
}

app.UseStaticFiles();

app.UseMvc(routes =>
app.UseRouting();

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



if(HybridSupport.IsElectronActive)
if (HybridSupport.IsElectronActive)
{
ElectronBootstrap();
}
Expand Down
Loading