Upgrade build flows (#729)

pull/735/head
Next Turn 2020-12-08 01:59:24 +08:00 committed by GitHub
parent f4dcdfc73e
commit 820f46e6bf
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
18 changed files with 137 additions and 121 deletions

View File

@ -4,6 +4,14 @@
<TreatWarningsAsErrors>true</TreatWarningsAsErrors> <TreatWarningsAsErrors>true</TreatWarningsAsErrors>
<DebugType>full</DebugType> <DebugType>full</DebugType>
<ArtifactsDir>$(MSBuildThisFileDirectory)artifacts\</ArtifactsDir> <ArtifactsDir>$(MSBuildThisFileDirectory)artifacts\</ArtifactsDir>
<ArtifactsBinDir>$(ArtifactsDir)bin\</ArtifactsBinDir>
<ArtifactsObjDir>$(ArtifactsDir)obj\</ArtifactsObjDir>
<ArtifactsPublishDir>$(ArtifactsDir)publish\</ArtifactsPublishDir>
</PropertyGroup>
<PropertyGroup>
<BaseOutputPath>$(ArtifactsBinDir)$(MSBuildProjectName)\</BaseOutputPath>
<BaseIntermediateOutputPath>$(ArtifactsObjDir)$(MSBuildProjectName)\</BaseIntermediateOutputPath>
</PropertyGroup> </PropertyGroup>
<ItemGroup> <ItemGroup>

View File

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

View File

@ -1,6 +1,6 @@
MIT License MIT License
Copyright (c) Kohsuke Kawaguchi, Sun Microsystems, Inc., CloudBees, Inc., Oleg Nenashev and other contributors Copyright (c) 2008-2020 Kohsuke Kawaguchi, Sun Microsystems, Inc., CloudBees, Inc., Oleg Nenashev and other contributors
Permission is hereby granted, free of charge, to any person obtaining a copy Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal of this software and associated documentation files (the "Software"), to deal

View File

@ -17,7 +17,7 @@ More info about the wrapper is available in the projects GitHub repository.
<license type="expression">MIT</license> <license type="expression">MIT</license>
<projectUrl>https://github.com/winsw/winsw</projectUrl> <projectUrl>https://github.com/winsw/winsw</projectUrl>
<!--<iconUrl>TODO</iconUrl>--> <!--<iconUrl>TODO</iconUrl>-->
<copyright>Copyright (c) 2010-2016 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>
<requireLicenseAcceptance>false</requireLicenseAcceptance> <requireLicenseAcceptance>false</requireLicenseAcceptance>
<tags>service wrapper</tags> <tags>service wrapper</tags>
<dependencies> <dependencies>
@ -25,9 +25,9 @@ More info about the wrapper is available in the projects GitHub repository.
</dependencies> </dependencies>
</metadata> </metadata>
<files> <files>
<file src="artifacts\WinSW.NET2.exe" target="lib\net20-full\WinSW.NET2.exe" /> <file src="artifacts\publish\WinSW.NET2.exe" target="lib\net20-full\WinSW.NET2.exe" />
<file src="artifacts\WinSW.NET4.exe" target="lib\net40-full\WinSW.NET4.exe" /> <file src="artifacts\publish\WinSW.NET4.exe" target="lib\net40-full\WinSW.NET4.exe" />
<file src="artifacts\WinSW.NET461.exe" target="lib\net461-full\WinSW.NET461.exe" /> <file src="artifacts\publish\WinSW.NET461.exe" target="lib\net461-full\WinSW.NET461.exe" />
<file src="examples\sample-allOptions.xml" target="lib\net20-full\WinSW.NET2.xml" /> <file src="examples\sample-allOptions.xml" target="lib\net20-full\WinSW.NET2.xml" />
<file src="examples\sample-allOptions.xml" target="lib\net40-full\WinSW.NET4.xml" /> <file src="examples\sample-allOptions.xml" target="lib\net40-full\WinSW.NET4.xml" />
<file src="examples\sample-allOptions.xml" target="lib\net461-full\WinSW.NET461.xml" /> <file src="examples\sample-allOptions.xml" target="lib\net461-full\WinSW.NET461.xml" />

View File

@ -28,11 +28,18 @@ jobs:
Release: Release:
BuildConfiguration: Release BuildConfiguration: Release
steps: steps:
- script: | - task: DotNetCoreCLI@2
dotnet build -c $(BuildConfiguration) src\WinSW.sln -p:Version=$(BuildVersion)
dotnet publish -c $(BuildConfiguration) -f netcoreapp3.1 -r win-x64 src\WinSW\WinSW.csproj -p:PublishSingleFile=true -p:PublishTrimmed=true -p:Version=$(BuildVersion)
dotnet publish -c $(BuildConfiguration) -f netcoreapp3.1 -r win-x86 src\WinSW\WinSW.csproj -p:PublishSingleFile=true -p:PublishTrimmed=true -p:Version=$(BuildVersion)
displayName: Build displayName: Build
inputs:
command: build
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)
displayName: Build
- script: dotnet test -c $(BuildConfiguration) --collect "XPlat Code Coverage" --no-build src\WinSW.Tests\WinSW.Tests.csproj
displayName: Test
- task: NuGetToolInstaller@1 - task: NuGetToolInstaller@1
displayName: Install Nuget displayName: Install Nuget
inputs: inputs:
@ -44,51 +51,41 @@ jobs:
packagesToPack: WinSW.nuspec packagesToPack: WinSW.nuspec
versioningScheme: byEnvVar versioningScheme: byEnvVar
versionEnvVar: BuildVersion versionEnvVar: BuildVersion
- script: dotnet test -c $(BuildConfiguration) --collect "XPlat Code Coverage" --no-build src\WinSW.Tests\WinSW.Tests.csproj
displayName: Test
- 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
- task: PublishBuildArtifacts@1
- publish: artifacts\publish\WinSW.NET2.exe
artifact: WinSW.NET2.exe_$(BuildConfiguration)
displayName: Publish .NET 2.0 displayName: Publish .NET 2.0
inputs:
PathtoPublish: artifacts\WinSW.NET2.exe - publish: artifacts\publish\WinSW.NET4.exe
ArtifactName: WinSW.NET2.exe_$(BuildConfiguration) artifact: WinSW.NET4.exe_$(BuildConfiguration)
- task: PublishBuildArtifacts@1
displayName: Publish .NET 4.0 displayName: Publish .NET 4.0
inputs:
PathtoPublish: artifacts\WinSW.NET4.exe - publish: artifacts\publish\WinSW.NET461.exe
ArtifactName: WinSW.NET4.exe_$(BuildConfiguration) artifact: WinSW.NET461.exe_$(BuildConfiguration)
- task: PublishBuildArtifacts@1
displayName: Publish .NET 4.6.1 displayName: Publish .NET 4.6.1
inputs:
PathtoPublish: artifacts\WinSW.NET461.exe - publish: artifacts\publish\WinSW-x64.exe
ArtifactName: WinSW.NET461.exe_$(BuildConfiguration) artifact: WinSW-x64.exe_$(BuildConfiguration)
- task: PublishBuildArtifacts@1 displayName: Publish .NET Core x64
displayName: Publish .NET Core 3.1 x64
inputs: - publish: artifacts\publish\WinSW-x86.exe
PathtoPublish: artifacts\WinSW.NETCore31.x64.exe artifact: WinSW-x86.exe_$(BuildConfiguration)
ArtifactName: WinSW.NETCore31.x64.exe_$(BuildConfiguration) displayName: Publish .NET Core x86
- task: PublishBuildArtifacts@1
displayName: Publish .NET Core 3.1 x86 - publish: $(Build.ArtifactStagingDirectory)\WinSW.$(BuildVersion).nupkg
inputs: artifact: WinSW.nupkg_$(BuildConfiguration)
PathtoPublish: artifacts\WinSW.NETCore31.x86.exe
ArtifactName: WinSW.NETCore31.x86.exe_$(BuildConfiguration)
- task: PublishBuildArtifacts@1
displayName: Publish Nuget displayName: Publish Nuget
inputs:
PathtoPublish: $(Build.ArtifactStagingDirectory)\WinSW.$(BuildVersion).nupkg - publish: examples\sample-allOptions.xml
ArtifactName: WinSW.nupkg_$(BuildConfiguration) artifact: sample-allOptions.xml
- task: PublishBuildArtifacts@1
displayName: Publish full sample displayName: Publish full sample
condition: and(succeeded(), eq(variables['BuildConfiguration'], 'Release')) condition: and(succeeded(), eq(variables['BuildConfiguration'], 'Release'))
inputs:
PathtoPublish: examples\sample-allOptions.xml - publish: examples\sample-minimal.xml
ArtifactName: sample-allOptions.xml artifact: sample-minimal.xml
- task: PublishBuildArtifacts@1
displayName: Publish minimal sample displayName: Publish minimal sample
condition: and(succeeded(), eq(variables['BuildConfiguration'], 'Release')) condition: and(succeeded(), eq(variables['BuildConfiguration'], 'Release'))
inputs:
PathtoPublish: examples\sample-minimal.xml
ArtifactName: sample-minimal.xml

View File

@ -1,20 +1,26 @@
<!-- <!--
Copyright (c) 2016 Oleg Nenashev and other contributors MIT License
Permission is hereby granted, free of charge, to any person obtaining a copy of this Copyright (c) 2008-2020 Kohsuke Kawaguchi, Sun Microsystems, Inc., CloudBees,
software and associated documentation files (the "Software"), to deal in the Software without Inc., Oleg Nenashev and other contributors
restriction, including without limitation the rights to use, copy, modify, merge, publish,
distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the
Software is furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all copies or Permission is hereby granted, free of charge, to any person obtaining a copy
substantial portions of the Software. of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING The above copyright notice and this permission notice shall be included in all
BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND copies or substantial portions of the Software.
NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM,
DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.
--> -->
<!-- <!--

View File

@ -1,20 +1,26 @@
<!-- <!--
Copyright (c) 2016 Oleg Nenashev and other contributors MIT License
Permission is hereby granted, free of charge, to any person obtaining a copy of this Copyright (c) 2008-2020 Kohsuke Kawaguchi, Sun Microsystems, Inc., CloudBees,
software and associated documentation files (the "Software"), to deal in the Software without Inc., Oleg Nenashev and other contributors
restriction, including without limitation the rights to use, copy, modify, merge, publish,
distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the
Software is furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all copies or Permission is hereby granted, free of charge, to any person obtaining a copy
substantial portions of the Software. of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING The above copyright notice and this permission notice shall be included in all
BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND copies or substantial portions of the Software.
NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM,
DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.
--> -->
<!-- <!--

View File

@ -24,7 +24,7 @@ namespace WinSW.Configuration
public bool HideWindow => false; public bool HideWindow => false;
public string ExecutablePath => Process.GetCurrentProcess().MainModule.FileName; public string ExecutablePath => Process.GetCurrentProcess().MainModule!.FileName!;
// Installation // Installation
public Native.SC_ACTION[] FailureActions => new Native.SC_ACTION[0]; public Native.SC_ACTION[] FailureActions => new Native.SC_ACTION[0];
@ -155,7 +155,7 @@ namespace WinSW.Configuration
{ {
get get
{ {
var d = new DirectoryInfo(Path.GetDirectoryName(this.ExecutablePath)); var d = new DirectoryInfo(Path.GetDirectoryName(this.ExecutablePath)!);
return Path.Combine(d.FullName, this.BaseName); return Path.Combine(d.FullName, this.BaseName);
} }
} }

View File

@ -226,7 +226,7 @@ namespace WinSW
} }
catch (WebException e) catch (WebException e)
{ {
if (supportsIfModifiedSince && ((HttpWebResponse)e.Response).StatusCode == HttpStatusCode.NotModified) if (supportsIfModifiedSince && ((HttpWebResponse?)e.Response)?.StatusCode == HttpStatusCode.NotModified)
{ {
Logger.Info($"Skipped downloading unmodified resource '{this.From}'"); Logger.Info($"Skipped downloading unmodified resource '{this.From}'");
} }

View File

@ -38,7 +38,7 @@ namespace WinSW.Extensions
catch (ExtensionException ex) catch (ExtensionException ex)
{ {
Log.Fatal("onWrapperStarted() handler failed for " + ext.Value.DisplayName, ex); Log.Fatal("onWrapperStarted() handler failed for " + ext.Value.DisplayName, ex);
throw ex; // Propagate error to stop the startup throw; // Propagate error to stop the startup
} }
} }
} }

View File

@ -222,7 +222,7 @@ namespace WinSW
List<string> result = new List<string>(extensions.Count); List<string> result = new List<string>(extensions.Count);
for (int i = 0; i < extensions.Count; i++) for (int i = 0; i < extensions.Count; i++)
{ {
result.Add(XmlHelper.SingleAttribute<string>((XmlElement)extensions[i], "id")); result.Add(XmlHelper.SingleAttribute<string>((XmlElement)extensions[i]!, "id"));
} }
return result; return result;
@ -245,12 +245,12 @@ namespace WinSW
StringBuilder arguments = new StringBuilder(); StringBuilder arguments = new StringBuilder();
XmlNodeList argumentNodeList = this.dom.SelectNodes("//" + tagName); XmlNodeList argumentNodeList = this.dom.SelectNodes("//" + tagName)!;
for (int i = 0; i < argumentNodeList.Count; i++) for (int i = 0; i < argumentNodeList.Count; i++)
{ {
arguments.Append(' '); arguments.Append(' ');
string token = Environment.ExpandEnvironmentVariables(argumentNodeList[i].InnerText); string token = Environment.ExpandEnvironmentVariables(argumentNodeList[i]!.InnerText);
if (token.StartsWith("\"") && token.EndsWith("\"")) if (token.StartsWith("\"") && token.EndsWith("\""))
{ {
@ -463,7 +463,7 @@ namespace WinSW
string[] serviceDependencies = new string[nodeList.Count]; string[] serviceDependencies = new string[nodeList.Count];
for (int i = 0; i < nodeList.Count; i++) for (int i = 0; i < nodeList.Count; i++)
{ {
serviceDependencies[i] = nodeList[i].InnerText; serviceDependencies[i] = nodeList[i]!.InnerText;
} }
return serviceDependencies; return serviceDependencies;
@ -582,8 +582,8 @@ namespace WinSW
SC_ACTION[] result = new SC_ACTION[childNodes.Count]; SC_ACTION[] result = new SC_ACTION[childNodes.Count];
for (int i = 0; i < childNodes.Count; i++) for (int i = 0; i < childNodes.Count; i++)
{ {
XmlNode node = childNodes[i]; XmlNode node = childNodes[i]!;
string action = node.Attributes["action"].Value; string action = node.Attributes!["action"]?.Value ?? throw new InvalidDataException("'action' is missing");
SC_ACTION_TYPE type = action switch SC_ACTION_TYPE type = action switch
{ {
"restart" => SC_ACTION_TYPE.SC_ACTION_RESTART, "restart" => SC_ACTION_TYPE.SC_ACTION_RESTART,
@ -689,13 +689,13 @@ namespace WinSW
private Dictionary<string, string> LoadEnvironmentVariables() private Dictionary<string, string> LoadEnvironmentVariables()
{ {
XmlNodeList nodeList = this.dom.SelectNodes("//env"); XmlNodeList nodeList = this.dom.SelectNodes("//env")!;
Dictionary<string, string> environment = new Dictionary<string, string>(nodeList.Count); Dictionary<string, string> environment = new Dictionary<string, string>(nodeList.Count);
for (int i = 0; i < nodeList.Count; i++) for (int i = 0; i < nodeList.Count; i++)
{ {
XmlNode node = nodeList[i]; XmlNode node = nodeList[i]!;
string key = node.Attributes["name"].Value; string key = node.Attributes!["name"]?.Value ?? throw new InvalidDataException("'name' is missing");
string value = Environment.ExpandEnvironmentVariables(node.Attributes["value"].Value); string value = Environment.ExpandEnvironmentVariables(node.Attributes["value"]?.Value ?? throw new InvalidDataException("'value' is missing"));
environment[key] = value; environment[key] = value;
Environment.SetEnvironmentVariable(key, value); Environment.SetEnvironmentVariable(key, value);

View File

@ -12,7 +12,7 @@ namespace WinSW.Util
{ {
public static void MoveOrReplaceFile(string sourceFileName, string destFileName) public static void MoveOrReplaceFile(string sourceFileName, string destFileName)
{ {
#if NETCOREAPP #if NET
File.Move(sourceFileName, destFileName, true); File.Move(sourceFileName, destFileName, true);
#else #else
string sourceFilePath = Path.GetFullPath(sourceFileName); string sourceFilePath = Path.GetFullPath(sourceFileName);

View File

@ -1,7 +1,7 @@
<Project Sdk="Microsoft.NET.Sdk"> <Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup> <PropertyGroup>
<TargetFrameworks>net20;net40;net461;netcoreapp3.1</TargetFrameworks> <TargetFrameworks>net20;net40;net461;net5.0-windows</TargetFrameworks>
<LangVersion>latest</LangVersion> <LangVersion>latest</LangVersion>
<Nullable>enable</Nullable> <Nullable>enable</Nullable>
<AllowUnsafeBlocks>true</AllowUnsafeBlocks> <AllowUnsafeBlocks>true</AllowUnsafeBlocks>
@ -18,14 +18,14 @@
</PackageReference> </PackageReference>
</ItemGroup> </ItemGroup>
<ItemGroup Condition="'$(TargetFramework)' == 'netcoreapp3.1'"> <ItemGroup Condition="'$(TargetFramework)' == 'net5.0-windows'">
<PackageReference Include="System.Diagnostics.EventLog" Version="4.7.0" /> <PackageReference Include="System.Diagnostics.EventLog" Version="4.7.0" />
<PackageReference Include="System.Management" Version="4.7.0" /> <PackageReference Include="System.Management" Version="4.7.0" />
<PackageReference Include="System.Security.AccessControl" Version="4.7.0" /> <PackageReference Include="System.Security.AccessControl" Version="4.7.0" />
</ItemGroup> </ItemGroup>
<!-- error NU1605: Detected package downgrade: log4net 2.0.8 --> <!-- error NU1605: Detected package downgrade: log4net 2.0.8 -->
<ItemGroup Condition="'$(TargetFramework)' == 'netcoreapp3.1'"> <ItemGroup Condition="'$(TargetFramework)' == 'net5.0-windows'">
<PackageReference Include="System.Diagnostics.Debug" Version="4.3.0" /> <PackageReference Include="System.Diagnostics.Debug" Version="4.3.0" />
<PackageReference Include="System.IO.FileSystem" Version="4.3.0" /> <PackageReference Include="System.IO.FileSystem" Version="4.3.0" />
<PackageReference Include="System.Net.NameResolution" Version="4.3.0" /> <PackageReference Include="System.Net.NameResolution" Version="4.3.0" />
@ -34,7 +34,7 @@
<PackageReference Include="System.Threading" Version="4.3.0" /> <PackageReference Include="System.Threading" Version="4.3.0" />
</ItemGroup> </ItemGroup>
<ItemGroup Condition="'$(TargetFramework)' != 'netcoreapp3.1'"> <ItemGroup Condition="'$(TargetFramework)' != 'net5.0-windows'">
<PackageReference Include="Microsoft.NETFramework.ReferenceAssemblies" Version="1.0.0" /> <PackageReference Include="Microsoft.NETFramework.ReferenceAssemblies" Version="1.0.0" />
<Reference Include="System.Management" /> <Reference Include="System.Management" />
</ItemGroup> </ItemGroup>

View File

@ -1,13 +1,13 @@
<Project Sdk="Microsoft.NET.Sdk"> <Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup> <PropertyGroup>
<TargetFrameworks>net20;net40;net461;netcoreapp3.1</TargetFrameworks> <TargetFrameworks>net20;net40;net461;net5.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)' != 'netcoreapp3.1'"> <ItemGroup Condition="'$(TargetFramework)' != 'net5.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;netcoreapp3.1</TargetFrameworks> <TargetFrameworks>net40;net461;net5.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)' != 'netcoreapp3.1'"> <ItemGroup Condition="'$(TargetFramework)' != 'net5.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

@ -4,7 +4,7 @@ using System.ComponentModel;
using System.Diagnostics; using System.Diagnostics;
using System.Diagnostics.CodeAnalysis; using System.Diagnostics.CodeAnalysis;
using System.IO; using System.IO;
#if NETCOREAPP #if NET
using System.Reflection; using System.Reflection;
#endif #endif
using System.Runtime.InteropServices; using System.Runtime.InteropServices;
@ -512,8 +512,8 @@ namespace WinSW
{ {
UseShellExecute = true, UseShellExecute = true,
Verb = "runas", Verb = "runas",
FileName = current.MainModule.FileName, FileName = current.MainModule!.FileName!,
#if NETCOREAPP #if NET
Arguments = "/elevated " + string.Join(' ', args), Arguments = "/elevated " + string.Join(' ', args),
#elif !NET20 #elif !NET20
Arguments = "/elevated " + string.Join(" ", args), Arguments = "/elevated " + string.Join(" ", args),
@ -525,7 +525,7 @@ namespace WinSW
try try
{ {
using Process elevated = Process.Start(startInfo); using Process elevated = Process.Start(startInfo)!;
elevated.WaitForExit(); elevated.WaitForExit();
Environment.Exit(elevated.ExitCode); Environment.Exit(elevated.ExitCode);
@ -596,7 +596,7 @@ namespace WinSW
appenders.Add(systemEventLogger); appenders.Add(systemEventLogger);
BasicConfigurator.Configure( BasicConfigurator.Configure(
#if NETCOREAPP #if NET
LogManager.GetRepository(Assembly.GetExecutingAssembly()), LogManager.GetRepository(Assembly.GetExecutingAssembly()),
#endif #endif
appenders.ToArray()); appenders.ToArray());
@ -664,7 +664,7 @@ namespace WinSW
var executablePath = new DefaultWinSWSettings().ExecutablePath; var executablePath = new DefaultWinSWSettings().ExecutablePath;
var baseName = Path.GetFileNameWithoutExtension(executablePath); var baseName = Path.GetFileNameWithoutExtension(executablePath);
var d = new DirectoryInfo(Path.GetDirectoryName(executablePath)); var d = new DirectoryInfo(Path.GetDirectoryName(executablePath)!);
if (File.Exists(Path.Combine(d.FullName, baseName + ".xml"))) if (File.Exists(Path.Combine(d.FullName, baseName + ".xml")))
{ {

View File

@ -2,27 +2,34 @@
<PropertyGroup> <PropertyGroup>
<OutputType>Exe</OutputType> <OutputType>Exe</OutputType>
<TargetFrameworks>net20;net40;net461;netcoreapp3.1</TargetFrameworks> <TargetFrameworks>net20;net40;net461;net5.0-windows</TargetFrameworks>
<LangVersion>latest</LangVersion> <LangVersion>latest</LangVersion>
<Nullable>enable</Nullable> <Nullable>enable</Nullable>
<AllowUnsafeBlocks>true</AllowUnsafeBlocks> <AllowUnsafeBlocks>true</AllowUnsafeBlocks>
<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>
<Company>CloudBees, Inc.</Company> <Company>CloudBees, Inc.</Company>
<Product>Windows Service Wrapper</Product> <Product>Windows Service Wrapper</Product>
<Copyright>Copyright 2008-2016 Oleg Nenashev, CloudBees, Inc. 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)' != 'netcoreapp3.1'"> <PropertyGroup Condition="'$(TargetFramework)' == 'net5.0-windows' AND '$(RuntimeIdentifier)' != ''">
<PublishSingleFile>true</PublishSingleFile>
<IncludeNativeLibrariesForSelfExtract>true</IncludeNativeLibrariesForSelfExtract>
</PropertyGroup>
<PropertyGroup Condition="'$(TargetFramework)' != 'net5.0-windows'">
<ILMergeVersion>3.0.41</ILMergeVersion> <ILMergeVersion>3.0.41</ILMergeVersion>
</PropertyGroup> </PropertyGroup>
<ItemGroup Condition="'$(TargetFramework)' == 'netcoreapp3.1'"> <ItemGroup Condition="'$(TargetFramework)' == 'net5.0-windows'">
<PackageReference Include="System.ServiceProcess.ServiceController" Version="4.7.0" /> <PackageReference Include="System.ServiceProcess.ServiceController" Version="4.7.0" />
</ItemGroup> </ItemGroup>
<ItemGroup Condition="'$(TargetFramework)' != 'netcoreapp3.1'"> <ItemGroup Condition="'$(TargetFramework)' != 'net5.0-windows'">
<PackageReference Include="ilmerge" Version="$(ILMergeVersion)" /> <PackageReference Include="ilmerge" Version="$(ILMergeVersion)" />
<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" />
@ -33,14 +40,7 @@
<ProjectReference Include="..\WinSW.Plugins\WinSW.Plugins.csproj" /> <ProjectReference Include="..\WinSW.Plugins\WinSW.Plugins.csproj" />
</ItemGroup> </ItemGroup>
<Target Name="PublishCoreZip" AfterTargets="Publish" Condition="'$(TargetFramework)' == 'netcoreapp3.1' and '$(RuntimeIdentifier)' == ''"> <Target Name="PublishCoreExe" AfterTargets="Publish" Condition="'$(TargetFramework)' == 'net5.0-windows'">
<MakeDir Directories="$(ArtifactsDir)" />
<ZipDirectory SourceDirectory="$(PublishDir)" DestinationFile="$(ArtifactsDir)WinSW.NETCore31.zip" Overwrite="true" />
</Target>
<Target Name="PublishCoreExe" AfterTargets="Publish" Condition="'$(TargetFramework)' == 'netcoreapp3.1' and '$(RuntimeIdentifier)' != ''">
<PropertyGroup Condition="'$(RuntimeIdentifier)' == 'win-x64'"> <PropertyGroup Condition="'$(RuntimeIdentifier)' == 'win-x64'">
<IdentifierSuffix>x64</IdentifierSuffix> <IdentifierSuffix>x64</IdentifierSuffix>
@ -50,13 +50,13 @@
<IdentifierSuffix>x86</IdentifierSuffix> <IdentifierSuffix>x86</IdentifierSuffix>
</PropertyGroup> </PropertyGroup>
<MakeDir Directories="$(ArtifactsDir)" /> <MakeDir Directories="$(ArtifactsPublishDir)" />
<Copy SourceFiles="$(PublishDir)$(TargetName).exe" DestinationFiles="$(ArtifactsDir)WinSW.NETCore31.$(IdentifierSuffix).exe" /> <Copy SourceFiles="$(PublishDir)$(TargetName).exe" DestinationFiles="$(ArtifactsPublishDir)WinSW-$(IdentifierSuffix).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)' != 'netcoreapp3.1'"> <Target Name="Merge" BeforeTargets="AfterBuild" Condition="'$(TargetFramework)' != 'net5.0-windows'">
<PropertyGroup Condition="'$(TargetFramework)' == 'net20'"> <PropertyGroup Condition="'$(TargetFramework)' == 'net20'">
<TargetPlatform>v2</TargetPlatform> <TargetPlatform>v2</TargetPlatform>
@ -80,7 +80,7 @@
<InputAssemblies>$(InputAssemblies) "$(OutDir)WinSW.Plugins.dll"</InputAssemblies> <InputAssemblies>$(InputAssemblies) "$(OutDir)WinSW.Plugins.dll"</InputAssemblies>
<InputAssemblies>$(InputAssemblies) "$(OutDir)log4net.dll"</InputAssemblies> <InputAssemblies>$(InputAssemblies) "$(OutDir)log4net.dll"</InputAssemblies>
<InputAssemblies>$(InputAssemblies) "$(OutDir)YamlDotNet.dll"</InputAssemblies> <InputAssemblies>$(InputAssemblies) "$(OutDir)YamlDotNet.dll"</InputAssemblies>
<OutputAssembly>"$(ArtifactsDir)WinSW.$(IdentifierSuffix).exe"</OutputAssembly> <OutputAssembly>"$(ArtifactsPublishDir)WinSW.$(IdentifierSuffix).exe"</OutputAssembly>
</PropertyGroup> </PropertyGroup>
<PropertyGroup Condition="'$(TargetFramework)' == 'net20' or '$(TargetFramework)' == 'net40'"> <PropertyGroup Condition="'$(TargetFramework)' == 'net20' or '$(TargetFramework)' == 'net40'">
@ -93,8 +93,7 @@
<ILMergeCommand>"$(ILMerge)" $(ILMergeArgs)</ILMergeCommand> <ILMergeCommand>"$(ILMerge)" $(ILMergeArgs)</ILMergeCommand>
</PropertyGroup> </PropertyGroup>
<MakeDir Directories="$(ArtifactsDir)" /> <MakeDir Directories="$(ArtifactsPublishDir)" />
<Message Text="$(ILMergeCommand)" Importance="high" />
<Exec Command="$(ILMergeCommand)" /> <Exec Command="$(ILMergeCommand)" />
</Target> </Target>

View File

@ -31,7 +31,7 @@ namespace WinSW
internal WinSWExtensionManager ExtensionManager { get; private set; } internal WinSWExtensionManager ExtensionManager { get; private set; }
private static readonly ILog Log = LogManager.GetLogger( private static readonly ILog Log = LogManager.GetLogger(
#if NETCOREAPP #if NET
Assembly.GetExecutingAssembly(), Assembly.GetExecutingAssembly(),
#endif #endif
"WinSW"); "WinSW");