Upgrade to .NET 6

pull/807/head
Next Turn 2021-03-17 00:00:00 +08:00
parent 2edcee7f49
commit d13b635b17
No known key found for this signature in database
GPG Key ID: 6A02A6770B9A88A0
7 changed files with 25 additions and 26 deletions

View File

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

View File

@ -26,6 +26,12 @@ strategy:
Release:
BuildConfiguration: Release
steps:
- task: UseDotNet@2
displayName: Install .NET SDK
inputs:
packageType: sdk
version: 6.x
includePreviewVersions: true
- task: DotNetCoreCLI@2
displayName: Build
inputs:
@ -33,8 +39,8 @@ steps:
projects: src\WinSW.sln
arguments: -c $(BuildConfiguration) -p:Version=$(BuildVersion)
- 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 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-x64 src\WinSW\WinSW.csproj -p:Version=$(BuildVersion)
dotnet publish -c $(BuildConfiguration) -f net6.0-windows -r win-x86 src\WinSW\WinSW.csproj -p:Version=$(BuildVersion)
displayName: Build
- script: dotnet test -c $(BuildConfiguration) --collect "XPlat Code Coverage" --no-build src\WinSW.Tests\WinSW.Tests.csproj
displayName: Test

View File

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

View File

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

View File

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

View File

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

View File

@ -2,7 +2,7 @@
<PropertyGroup>
<OutputType>Exe</OutputType>
<TargetFrameworks>net20;net40;net461;net5.0-windows</TargetFrameworks>
<TargetFrameworks>net20;net40;net461;net6.0-windows</TargetFrameworks>
<LangVersion>latest</LangVersion>
<Nullable>enable</Nullable>
<AllowUnsafeBlocks>true</AllowUnsafeBlocks>
@ -16,16 +16,15 @@
<Copyright>Copyright (c) 2008-2020 Kohsuke Kawaguchi, Sun Microsystems, Inc., CloudBees, Inc., Oleg Nenashev and other contributors</Copyright>
</PropertyGroup>
<PropertyGroup Condition="'$(TargetFramework)' == 'net5.0-windows' AND '$(RuntimeIdentifier)' != ''">
<PropertyGroup Condition="'$(TargetFramework)' == 'net6.0-windows' AND '$(RuntimeIdentifier)' != ''">
<PublishSingleFile>true</PublishSingleFile>
<IncludeNativeLibrariesForSelfExtract>true</IncludeNativeLibrariesForSelfExtract>
</PropertyGroup>
<PropertyGroup Condition="'$(TargetFramework)' != 'net5.0-windows'">
<PropertyGroup Condition="'$(TargetFramework)' != 'net6.0-windows'">
<ILMergeVersion>3.0.41</ILMergeVersion>
</PropertyGroup>
<ItemGroup Condition="'$(TargetFramework)' != 'net5.0-windows'">
<ItemGroup Condition="'$(TargetFramework)' != 'net6.0-windows'">
<PackageReference Include="ilmerge" Version="$(ILMergeVersion)" />
<Reference Include="System.ServiceProcess" />
</ItemGroup>
@ -35,23 +34,15 @@
<ProjectReference Include="..\WinSW.Plugins\WinSW.Plugins.csproj" />
</ItemGroup>
<Target Name="PublishCoreExe" AfterTargets="Publish" Condition="'$(TargetFramework)' == 'net5.0-windows'">
<PropertyGroup Condition="'$(RuntimeIdentifier)' == 'win-x64'">
<IdentifierSuffix>x64</IdentifierSuffix>
</PropertyGroup>
<PropertyGroup Condition="'$(RuntimeIdentifier)' == 'win-x86'">
<IdentifierSuffix>x86</IdentifierSuffix>
</PropertyGroup>
<Target Name="PublishCoreExe" AfterTargets="Publish" Condition="'$(TargetFramework)' == 'net6.0-windows'">
<MakeDir Directories="$(ArtifactsPublishDir)" />
<Copy SourceFiles="$(PublishDir)$(TargetName).exe" DestinationFiles="$(ArtifactsPublishDir)WinSW-$(IdentifierSuffix).exe" />
<Copy SourceFiles="$(PublishDir)$(TargetName).exe" DestinationFiles="$(ArtifactsPublishDir)WinSW-$(PlatformTarget).exe" />
</Target>
<!-- 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'">
<TargetPlatform>v2</TargetPlatform>