Upgrade to .NET 6 (#807)

* Upgrade to .NET 6

* Bump Codecov.Tool to 1.13.0

* Don't treat ILLink warnings as errors

* Update build.yml
pull/854/head
Next Turn 2021-08-09 11:47:34 +08:00 committed by GitHub
parent e380e6c64e
commit 20846238ea
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
9 changed files with 31 additions and 32 deletions

View File

@ -3,7 +3,7 @@
"isRoot": true, "isRoot": true,
"tools": { "tools": {
"codecov.tool": { "codecov.tool": {
"version": "1.12.1", "version": "1.13.0",
"commands": [ "commands": [
"codecov" "codecov"
] ]

View File

@ -2,6 +2,7 @@
<PropertyGroup> <PropertyGroup>
<TreatWarningsAsErrors>true</TreatWarningsAsErrors> <TreatWarningsAsErrors>true</TreatWarningsAsErrors>
<ILLinkTreatWarningsAsErrors>false</ILLinkTreatWarningsAsErrors>
<DebugType>full</DebugType> <DebugType>full</DebugType>
<ArtifactsDir>$(MSBuildThisFileDirectory)artifacts\</ArtifactsDir> <ArtifactsDir>$(MSBuildThisFileDirectory)artifacts\</ArtifactsDir>
<ArtifactsBinDir>$(ArtifactsDir)bin\</ArtifactsBinDir> <ArtifactsBinDir>$(ArtifactsDir)bin\</ArtifactsBinDir>

View File

@ -1,6 +1,6 @@
<Project> <Project>
<PropertyGroup Condition="'$(TargetFramework)' == 'net461' or '$(TargetFramework)' == 'net5.0-windows'"> <PropertyGroup Condition="'$(TargetFramework)' == 'net461' or '$(TargetFramework)' == 'net6.0-windows'">
<DefineConstants>VNEXT</DefineConstants> <DefineConstants>VNEXT</DefineConstants>
</PropertyGroup> </PropertyGroup>

View File

@ -26,6 +26,12 @@ strategy:
Release: Release:
BuildConfiguration: Release BuildConfiguration: Release
steps: steps:
- task: UseDotNet@2
displayName: Install .NET SDK
inputs:
packageType: sdk
version: 6.x
includePreviewVersions: true
- task: DotNetCoreCLI@2 - task: DotNetCoreCLI@2
displayName: Build displayName: Build
inputs: inputs:
@ -33,8 +39,8 @@ steps:
projects: src\WinSW.sln projects: src\WinSW.sln
arguments: -c $(BuildConfiguration) -p:Version=$(BuildVersion) arguments: -c $(BuildConfiguration) -p:Version=$(BuildVersion)
- script: | - script: |
dotnet publish -c $(BuildConfiguration) -f net5.0-windows -r win-x64 src\WinSW\WinSW.csproj -p:PublishSingleFile=true -p:PublishTrimmed=true -p:Version=$(BuildVersion) dotnet publish -c $(BuildConfiguration) -f net6.0-windows -r win-x64 src\WinSW\WinSW.csproj -p:Version=$(BuildVersion)
dotnet publish -c $(BuildConfiguration) -f net5.0-windows -r win-x86 src\WinSW\WinSW.csproj -p:PublishSingleFile=true -p:PublishTrimmed=true -p:Version=$(BuildVersion) dotnet publish -c $(BuildConfiguration) -f net6.0-windows -r win-x86 src\WinSW\WinSW.csproj -p:Version=$(BuildVersion)
displayName: Build displayName: Build
- script: dotnet test -c $(BuildConfiguration) --collect "XPlat Code Coverage" --no-build src\WinSW.Tests\WinSW.Tests.csproj - script: dotnet test -c $(BuildConfiguration) --collect "XPlat Code Coverage" --no-build src\WinSW.Tests\WinSW.Tests.csproj
displayName: Test displayName: Test
@ -47,8 +53,8 @@ steps:
versionEnvVar: BuildVersion versionEnvVar: BuildVersion
- script: dotnet tool restore - script: dotnet tool restore
displayName: Restore tools displayName: Restore tools
- script: dotnet tool run codecov -- -f "src\**\TestResults\*\coverage.cobertura.xml" --required # - script: dotnet tool run codecov -- -f "src\**\TestResults\*\coverage.cobertura.xml" --required
displayName: Upload code coverage reports # displayName: Upload code coverage reports
- publish: artifacts\publish\WinSW.NET2.exe - publish: artifacts\publish\WinSW.NET2.exe
artifact: WinSW.NET2.exe_$(BuildConfiguration) artifact: WinSW.NET2.exe_$(BuildConfiguration)
@ -64,11 +70,11 @@ steps:
- publish: artifacts\publish\WinSW-x64.exe - publish: artifacts\publish\WinSW-x64.exe
artifact: WinSW-x64.exe_$(BuildConfiguration) artifact: WinSW-x64.exe_$(BuildConfiguration)
displayName: Publish .NET Core x64 displayName: Publish .NET x64
- publish: artifacts\publish\WinSW-x86.exe - publish: artifacts\publish\WinSW-x86.exe
artifact: WinSW-x86.exe_$(BuildConfiguration) artifact: WinSW-x86.exe_$(BuildConfiguration)
displayName: Publish .NET Core x86 displayName: Publish .NET x86
- publish: $(Build.ArtifactStagingDirectory)\WinSW.$(BuildVersion).nupkg - publish: $(Build.ArtifactStagingDirectory)\WinSW.$(BuildVersion).nupkg
artifact: WinSW.nupkg_$(BuildConfiguration) artifact: WinSW.nupkg_$(BuildConfiguration)

View File

@ -150,7 +150,9 @@ namespace WinSW
public void Perform() public void Perform()
#endif #endif
{ {
#pragma warning disable SYSLIB0014 // Type or member is obsolete
var request = WebRequest.Create(this.From); var request = WebRequest.Create(this.From);
#pragma warning restore SYSLIB0014 // Type or member is obsolete
if (!string.IsNullOrEmpty(this.Proxy)) if (!string.IsNullOrEmpty(this.Proxy))
{ {
var proxyInformation = new CustomProxyInformation(this.Proxy!); var proxyInformation = new CustomProxyInformation(this.Proxy!);

View File

@ -1,7 +1,7 @@
<Project Sdk="Microsoft.NET.Sdk"> <Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup> <PropertyGroup>
<TargetFrameworks>net20;net40;net461;net5.0-windows</TargetFrameworks> <TargetFrameworks>net20;net40;net461;net6.0-windows</TargetFrameworks>
<LangVersion>latest</LangVersion> <LangVersion>latest</LangVersion>
<Nullable>enable</Nullable> <Nullable>enable</Nullable>
<AllowUnsafeBlocks>true</AllowUnsafeBlocks> <AllowUnsafeBlocks>true</AllowUnsafeBlocks>
@ -18,12 +18,12 @@
</PackageReference> </PackageReference>
</ItemGroup> </ItemGroup>
<ItemGroup Condition="'$(TargetFramework)' == 'net5.0-windows'"> <ItemGroup Condition="'$(TargetFramework)' == 'net6.0-windows'">
<PackageReference Include="System.Security.AccessControl" Version="5.0.0" /> <PackageReference Include="System.Security.AccessControl" Version="5.0.0" />
<PackageReference Include="System.ServiceProcess.ServiceController" Version="5.0.0" /> <PackageReference Include="System.ServiceProcess.ServiceController" Version="5.0.0" />
</ItemGroup> </ItemGroup>
<ItemGroup Condition="'$(TargetFramework)' != 'net5.0-windows'"> <ItemGroup Condition="'$(TargetFramework)' != 'net6.0-windows'">
<Reference Include="System.ServiceProcess" /> <Reference Include="System.ServiceProcess" />
</ItemGroup> </ItemGroup>

View File

@ -1,13 +1,13 @@
<Project Sdk="Microsoft.NET.Sdk"> <Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup> <PropertyGroup>
<TargetFrameworks>net20;net40;net461;net5.0-windows</TargetFrameworks> <TargetFrameworks>net20;net40;net461;net6.0-windows</TargetFrameworks>
<LangVersion>latest</LangVersion> <LangVersion>latest</LangVersion>
<Nullable>enable</Nullable> <Nullable>enable</Nullable>
<AllowUnsafeBlocks>true</AllowUnsafeBlocks> <AllowUnsafeBlocks>true</AllowUnsafeBlocks>
</PropertyGroup> </PropertyGroup>
<ItemGroup Condition="'$(TargetFramework)' != 'net5.0-windows'"> <ItemGroup Condition="'$(TargetFramework)' != 'net6.0-windows'">
<PackageReference Include="Microsoft.NETFramework.ReferenceAssemblies" Version="1.0.0" /> <PackageReference Include="Microsoft.NETFramework.ReferenceAssemblies" Version="1.0.0" />
</ItemGroup> </ItemGroup>

View File

@ -1,7 +1,7 @@
<Project Sdk="Microsoft.NET.Sdk"> <Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup> <PropertyGroup>
<TargetFrameworks>net40;net461;net5.0-windows</TargetFrameworks> <TargetFrameworks>net40;net461;net6.0-windows</TargetFrameworks>
<LangVersion>latest</LangVersion> <LangVersion>latest</LangVersion>
</PropertyGroup> </PropertyGroup>
@ -15,7 +15,7 @@
<PackageReference Include="NUnit3TestAdapter" Version="3.17.0" /> <PackageReference Include="NUnit3TestAdapter" Version="3.17.0" />
</ItemGroup> </ItemGroup>
<ItemGroup Condition="'$(TargetFramework)' != 'net5.0-windows'"> <ItemGroup Condition="'$(TargetFramework)' != 'net6.0-windows'">
<PackageReference Include="Microsoft.NETFramework.ReferenceAssemblies" Version="1.0.0" /> <PackageReference Include="Microsoft.NETFramework.ReferenceAssemblies" Version="1.0.0" />
<Reference Include="System.ServiceProcess" /> <Reference Include="System.ServiceProcess" />
</ItemGroup> </ItemGroup>

View File

@ -2,12 +2,11 @@
<PropertyGroup> <PropertyGroup>
<OutputType>Exe</OutputType> <OutputType>Exe</OutputType>
<TargetFrameworks>net20;net40;net461;net5.0-windows</TargetFrameworks> <TargetFrameworks>net20;net40;net461;net6.0-windows</TargetFrameworks>
<LangVersion>latest</LangVersion> <LangVersion>latest</LangVersion>
<Nullable>enable</Nullable> <Nullable>enable</Nullable>
<AllowUnsafeBlocks>true</AllowUnsafeBlocks> <AllowUnsafeBlocks>true</AllowUnsafeBlocks>
<PublishTrimmed>true</PublishTrimmed> <PublishTrimmed>true</PublishTrimmed>
<TrimMode>Link</TrimMode>
<AssemblyTitle>Windows Service Wrapper</AssemblyTitle> <AssemblyTitle>Windows Service Wrapper</AssemblyTitle>
<Description>Allows arbitrary process to run as a Windows service by wrapping it.</Description> <Description>Allows arbitrary process to run as a Windows service by wrapping it.</Description>
@ -16,16 +15,15 @@
<Copyright>Copyright (c) 2008-2020 Kohsuke Kawaguchi, Sun Microsystems, Inc., CloudBees, Inc., Oleg Nenashev and other contributors</Copyright> <Copyright>Copyright (c) 2008-2020 Kohsuke Kawaguchi, Sun Microsystems, Inc., CloudBees, Inc., Oleg Nenashev and other contributors</Copyright>
</PropertyGroup> </PropertyGroup>
<PropertyGroup Condition="'$(TargetFramework)' == 'net5.0-windows' AND '$(RuntimeIdentifier)' != ''"> <PropertyGroup Condition="'$(TargetFramework)' == 'net6.0-windows' AND '$(RuntimeIdentifier)' != ''">
<PublishSingleFile>true</PublishSingleFile> <PublishSingleFile>true</PublishSingleFile>
<IncludeNativeLibrariesForSelfExtract>true</IncludeNativeLibrariesForSelfExtract>
</PropertyGroup> </PropertyGroup>
<PropertyGroup Condition="'$(TargetFramework)' != 'net5.0-windows'"> <PropertyGroup Condition="'$(TargetFramework)' != 'net6.0-windows'">
<ILMergeVersion>3.0.41</ILMergeVersion> <ILMergeVersion>3.0.41</ILMergeVersion>
</PropertyGroup> </PropertyGroup>
<ItemGroup Condition="'$(TargetFramework)' != 'net5.0-windows'"> <ItemGroup Condition="'$(TargetFramework)' != 'net6.0-windows'">
<PackageReference Include="ilmerge" Version="$(ILMergeVersion)" /> <PackageReference Include="ilmerge" Version="$(ILMergeVersion)" />
<Reference Include="System.ServiceProcess" /> <Reference Include="System.ServiceProcess" />
</ItemGroup> </ItemGroup>
@ -35,23 +33,15 @@
<ProjectReference Include="..\WinSW.Plugins\WinSW.Plugins.csproj" /> <ProjectReference Include="..\WinSW.Plugins\WinSW.Plugins.csproj" />
</ItemGroup> </ItemGroup>
<Target Name="PublishCoreExe" AfterTargets="Publish" Condition="'$(TargetFramework)' == 'net5.0-windows'"> <Target Name="PublishCoreExe" AfterTargets="Publish" Condition="'$(TargetFramework)' == 'net6.0-windows'">
<PropertyGroup Condition="'$(RuntimeIdentifier)' == 'win-x64'">
<IdentifierSuffix>x64</IdentifierSuffix>
</PropertyGroup>
<PropertyGroup Condition="'$(RuntimeIdentifier)' == 'win-x86'">
<IdentifierSuffix>x86</IdentifierSuffix>
</PropertyGroup>
<MakeDir Directories="$(ArtifactsPublishDir)" /> <MakeDir Directories="$(ArtifactsPublishDir)" />
<Copy SourceFiles="$(PublishDir)$(TargetName).exe" DestinationFiles="$(ArtifactsPublishDir)WinSW-$(IdentifierSuffix).exe" /> <Copy SourceFiles="$(PublishDir)$(TargetName).exe" DestinationFiles="$(ArtifactsPublishDir)WinSW-$(PlatformTarget).exe" />
</Target> </Target>
<!-- Merge plugins and other DLLs into the executable --> <!-- Merge plugins and other DLLs into the executable -->
<Target Name="Merge" BeforeTargets="AfterBuild" Condition="'$(TargetFramework)' != 'net5.0-windows'"> <Target Name="Merge" BeforeTargets="AfterBuild" Condition="'$(TargetFramework)' != 'net6.0-windows'">
<PropertyGroup Condition="'$(TargetFramework)' == 'net20'"> <PropertyGroup Condition="'$(TargetFramework)' == 'net20'">
<TargetPlatform>v2</TargetPlatform> <TargetPlatform>v2</TargetPlatform>