diff --git a/eng/build.yml b/eng/build.yml index 28c9a1e..0c65cdf 100644 --- a/eng/build.yml +++ b/eng/build.yml @@ -40,10 +40,10 @@ jobs: projects: src\WinSW.sln arguments: -c $(BuildConfiguration) -p:Version=$(BuildVersion) - script: | - dotnet publish src\WinSW\WinSW.csproj -c $(BuildConfiguration) -f net5.0 -r win-x64 -p:Version=$(BuildVersion) - dotnet publish src\WinSW\WinSW.csproj -c $(BuildConfiguration) -f net5.0 -r win-x86 -p:Version=$(BuildVersion) - dotnet publish src\WinSW\WinSW.csproj -c $(BuildConfiguration) -f net5.0 -r win-x64 -p:Version=$(BuildVersion) -p:IncludeNativeLibrariesInSingleFile=true - dotnet publish src\WinSW\WinSW.csproj -c $(BuildConfiguration) -f net5.0 -r win-x86 -p:Version=$(BuildVersion) -p:IncludeNativeLibrariesInSingleFile=true + dotnet publish src\WinSW\WinSW.csproj -c $(BuildConfiguration) -f net5.0-windows -r win-x64 -p:Version=$(BuildVersion) + dotnet publish src\WinSW\WinSW.csproj -c $(BuildConfiguration) -f net5.0-windows -r win-x86 -p:Version=$(BuildVersion) + dotnet publish src\WinSW\WinSW.csproj -c $(BuildConfiguration) -f net5.0-windows -r win-x64 -p:Version=$(BuildVersion) -p:IncludeNativeLibrariesInSingleFile=true + dotnet publish src\WinSW\WinSW.csproj -c $(BuildConfiguration) -f net5.0-windows -r win-x86 -p:Version=$(BuildVersion) -p:IncludeNativeLibrariesInSingleFile=true displayName: Build - task: DotNetCoreCLI@2 displayName: Test diff --git a/src/WinSW.Core/Configuration/XmlServiceConfig.cs b/src/WinSW.Core/Configuration/XmlServiceConfig.cs index bd86039..22c5ee6 100644 --- a/src/WinSW.Core/Configuration/XmlServiceConfig.cs +++ b/src/WinSW.Core/Configuration/XmlServiceConfig.cs @@ -241,7 +241,7 @@ namespace WinSW List result = new List(extensions.Count); for (int i = 0; i < extensions.Count; i++) { - result.Add(XmlHelper.SingleAttribute((XmlElement)extensions[i], "id")); + result.Add(XmlHelper.SingleAttribute((XmlElement)extensions[i]!, "id")); } return result; @@ -264,12 +264,12 @@ namespace WinSW StringBuilder arguments = new StringBuilder(); - XmlNodeList argumentNodeList = this.dom.SelectNodes("//" + tagName); + XmlNodeList argumentNodeList = this.dom.SelectNodes("//" + tagName)!; for (int i = 0; i < argumentNodeList.Count; i++) { arguments.Append(' '); - string token = Environment.ExpandEnvironmentVariables(argumentNodeList[i].InnerText); + string token = Environment.ExpandEnvironmentVariables(argumentNodeList[i]!.InnerText); if (token.StartsWith("\"") && token.EndsWith("\"")) { @@ -471,7 +471,7 @@ namespace WinSW string[] serviceDependencies = new string[nodeList.Count]; for (int i = 0; i < nodeList.Count; i++) { - serviceDependencies[i] = nodeList[i].InnerText; + serviceDependencies[i] = nodeList[i]!.InnerText; } return serviceDependencies; @@ -588,8 +588,8 @@ namespace WinSW SC_ACTION[] result = new SC_ACTION[childNodes.Count]; for (int i = 0; i < childNodes.Count; i++) { - XmlNode node = childNodes[i]; - string action = node.Attributes["action"].Value; + XmlNode node = childNodes[i]!; + string action = node.Attributes!["action"]?.Value ?? throw new InvalidDataException("'action' is missing"); SC_ACTION_TYPE type = action switch { "restart" => SC_ACTION_TYPE.SC_ACTION_RESTART, @@ -682,13 +682,13 @@ namespace WinSW private Dictionary LoadEnvironmentVariables() { - XmlNodeList nodeList = this.dom.SelectNodes("//env"); + XmlNodeList nodeList = this.dom.SelectNodes("//env")!; Dictionary environment = new Dictionary(nodeList.Count); for (int i = 0; i < nodeList.Count; i++) { - XmlNode node = nodeList[i]; - string key = node.Attributes["name"].Value; - string value = Environment.ExpandEnvironmentVariables(node.Attributes["value"].Value); + XmlNode node = nodeList[i]!; + string key = node.Attributes!["name"]?.Value ?? throw new InvalidDataException("'name' is missing"); + string value = Environment.ExpandEnvironmentVariables(node.Attributes["value"]?.Value ?? throw new InvalidDataException("'value' is missing")); environment[key] = value; Environment.SetEnvironmentVariable(key, value); diff --git a/src/WinSW.Core/Extensions/WinSWExtensionManager.cs b/src/WinSW.Core/Extensions/WinSWExtensionManager.cs index b49768b..b34e3bc 100644 --- a/src/WinSW.Core/Extensions/WinSWExtensionManager.cs +++ b/src/WinSW.Core/Extensions/WinSWExtensionManager.cs @@ -63,7 +63,7 @@ namespace WinSW.Extensions catch (ExtensionException 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 } } } diff --git a/src/WinSW.Core/WinSW.Core.csproj b/src/WinSW.Core/WinSW.Core.csproj index 50959be..846a74c 100644 --- a/src/WinSW.Core/WinSW.Core.csproj +++ b/src/WinSW.Core/WinSW.Core.csproj @@ -1,7 +1,7 @@  - net461;net5.0 + net461;net5.0-windows preview enable true @@ -15,14 +15,14 @@ - + - + @@ -32,7 +32,7 @@ - + diff --git a/src/WinSW.Plugins/WinSW.Plugins.csproj b/src/WinSW.Plugins/WinSW.Plugins.csproj index 495b320..9dde121 100644 --- a/src/WinSW.Plugins/WinSW.Plugins.csproj +++ b/src/WinSW.Plugins/WinSW.Plugins.csproj @@ -1,7 +1,7 @@  - net461;net5.0 + net461;net5.0-windows latest enable diff --git a/src/WinSW.Tests/Util/InterProcessCodeCoverageSession.cs b/src/WinSW.Tests/Util/InterProcessCodeCoverageSession.cs index 0e01ece..7896137 100644 --- a/src/WinSW.Tests/Util/InterProcessCodeCoverageSession.cs +++ b/src/WinSW.Tests/Util/InterProcessCodeCoverageSession.cs @@ -48,8 +48,10 @@ namespace WinSW.Tests.Util hr = client.SetEventCallbacks(this); AssertEx.Succeeded(hr); +#pragma warning disable CA1416 // Validate platform compatibility IntPtr pointer = Marshal.GetIUnknownForObject(client); Assert.Equal(1, Marshal.Release(pointer)); +#pragma warning restore CA1416 // Validate platform compatibility target = DataTarget.CreateFromDbgEng(pointer); diff --git a/src/WinSW.Tests/WinSW.Tests.csproj b/src/WinSW.Tests/WinSW.Tests.csproj index 3ec54ec..443cfd0 100644 --- a/src/WinSW.Tests/WinSW.Tests.csproj +++ b/src/WinSW.Tests/WinSW.Tests.csproj @@ -1,7 +1,7 @@  - net471;net5.0 + net471;net5.0-windows latest @@ -20,7 +20,7 @@ - + @@ -39,11 +39,11 @@ - - <_FilesToCopy Include="$(ArtifactsBinDir)WinSW\$(Configuration)\net5.0\WinSW.runtimeconfig*.json" /> + + <_FilesToCopy Include="$(ArtifactsBinDir)WinSW\$(Configuration)\net5.0-windows\WinSW.runtimeconfig*.json" /> - + <_FilesToCopy Include="$(ArtifactsBinDir)WinSW\$(Configuration)\net461\System.ValueTuple.dll" /> diff --git a/src/WinSW/WinSW.csproj b/src/WinSW/WinSW.csproj index 0ff7ba0..f97b10f 100644 --- a/src/WinSW/WinSW.csproj +++ b/src/WinSW/WinSW.csproj @@ -2,7 +2,7 @@ Exe - net461;net5.0 + net461;net5.0-windows preview enable true @@ -16,11 +16,11 @@ Copyright (c) 2008-2020 Kohsuke Kawaguchi, Sun Microsystems, Inc., CloudBees, Inc., Oleg Nenashev and other contributors - + true - + 3.0.41 @@ -28,11 +28,11 @@ - + - + @@ -42,20 +42,20 @@ - + false - + - + @@ -63,7 +63,7 @@ - + NET461 @@ -95,7 +95,7 @@ - +