Browse Source

Produce ready-to-publish artifacts in build phase for AppVeyor

NextTurn 6 years ago
parent
commit
ab22212252
5 changed files with 40 additions and 11 deletions
  1. 1 0
      .gitignore
  2. 1 0
      Directory.Build.props
  3. 4 4
      WinSW.nuspec
  4. 6 6
      appveyor.yml
  5. 28 1
      src/Core/ServiceWrapper/winsw.csproj

+ 1 - 0
.gitignore

@@ -8,3 +8,4 @@ obj
 /winsw_key.pfx
 /src/.vs/
 /src/Core/WinSWCore/WinSWCore.csproj.DotSettings
+/artifacts/

+ 1 - 0
Directory.Build.props

@@ -3,6 +3,7 @@
   <PropertyGroup>
     <DebugType>full</DebugType>
     <AssemblyOriginatorKeyFile>$(MSBuildThisFileDirectory)winsw_key.snk</AssemblyOriginatorKeyFile>
+    <ArtifactsDir>$(MSBuildThisFileDirectory)artifacts\</ArtifactsDir>
   </PropertyGroup>
 
 </Project>

+ 4 - 4
WinSW.nuspec

@@ -25,9 +25,9 @@ More info about the wrapper is available in the projects GitHub repository.
     </dependencies>
   </metadata>
   <files>
-    <file src="src\Core\ServiceWrapper\bin\Release\net20\WinSW.exe" target="lib\net20-full\WinSW.NET2.exe" />
-    <file src="src\Core\ServiceWrapper\bin\Release\net40\WinSW.exe" target="lib\net40-full\WinSW.NET4.exe" />
-	<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="artifacts\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="examples\sample-allOptions.xml" target="lib\net20-full\WinSW.NET2.xml" />
+    <file src="examples\sample-allOptions.xml" target="lib\net40-full\WinSW.NET4.xml" />
   </files>
 </package>

+ 6 - 6
appveyor.yml

@@ -38,17 +38,17 @@ test_script:
   - dotnet.exe test -f netcoreapp3.1 --no-build src\Test\winswTests\winswTests.csproj
 
 artifacts:
-  - path: 'src\Core\ServiceWrapper\bin\Release\net20\WinSW.exe'
+  - path: artifacts\WinSW.NET2.exe
     name: WinSW.NET2.exe
-  - path: 'src\Core\ServiceWrapper\bin\Release\net40\WinSW.exe'
+  - path: artifacts\WinSW.NET4.exe
     name: WinSW.NET4.exe
-  - path: 'src\Core\ServiceWrapper\bin\Release\net461\WinSW.exe'
+  - path: artifacts\WinSW.NET461.exe
     name: WinSW.NET461.exe
-  - path: 'src\Core\ServiceWrapper\bin\Release\netcoreapp3.1\publish\'
+  - path: artifacts\WinSW.NETCore31.zip
     name: WinSW.NETCore31.zip
-  - path: 'src\Core\ServiceWrapper\bin\Release\netcoreapp3.1\win-x64\publish\WindowsService.exe'
+  - path: artifacts\WinSW.NETCore31.x64.exe
     name: WinSW.NETCore31.x64.exe
-  - path: 'src\Core\ServiceWrapper\bin\Release\netcoreapp3.1\win-x86\publish\WindowsService.exe'
+  - path: artifacts\WinSW.NETCore31.x86.exe
     name: WinSW.NETCore31.x86.exe
   - path: 'WinSW.$(appveyor_build_version).nupkg'
     name: WinSW.nupkg

+ 28 - 1
src/Core/ServiceWrapper/winsw.csproj

@@ -46,19 +46,45 @@
     <ProjectReference Include="..\..\Plugins\SharedDirectoryMapper\SharedDirectoryMapper.csproj" />
   </ItemGroup>
 
+  <Target Name="PublishCoreZip" AfterTargets="Publish" Condition="'$(TargetFramework)' == 'netcoreapp3.1' and '$(RuntimeIdentifier)' == ''">
+
+    <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'">
+      <IdentifierSuffix>x64</IdentifierSuffix>
+    </PropertyGroup>
+
+    <PropertyGroup Condition="'$(RuntimeIdentifier)' == 'win-x86'">
+      <IdentifierSuffix>x86</IdentifierSuffix>
+    </PropertyGroup>
+
+    <MakeDir Directories="$(ArtifactsDir)" />
+    <Copy SourceFiles="$(PublishDir)$(TargetName).exe" DestinationFiles="$(ArtifactsDir)WinSW.NETCore31.$(IdentifierSuffix).exe" />
+
+  </Target>
+
   <!-- Merge plugins and other DLLs into the executable -->
   <Target Name="Merge" BeforeTargets="AfterBuild" Condition="'$(TargetFramework)' != 'netcoreapp3.1'">
 
     <PropertyGroup Condition="'$(TargetFramework)' == 'net20'">
       <TargetPlatform>v2</TargetPlatform>
+      <IdentifierSuffix>NET2</IdentifierSuffix>
     </PropertyGroup>
 
     <PropertyGroup Condition="'$(TargetFramework)' == 'net40'">
       <TargetPlatform>v4</TargetPlatform>
+      <IdentifierSuffix>NET4</IdentifierSuffix>
     </PropertyGroup>
 
     <PropertyGroup Condition="'$(TargetFramework)' == 'net461'">
+      <!-- v4.5+ -->
       <TargetPlatform>v4.5</TargetPlatform>
+      <IdentifierSuffix>NET461</IdentifierSuffix>
     </PropertyGroup>
 
     <PropertyGroup>
@@ -67,7 +93,7 @@
       <InputAssemblies>$(InputAssemblies) "$(OutDir)SharedDirectoryMapper.dll"</InputAssemblies>
       <InputAssemblies>$(InputAssemblies) "$(OutDir)RunawayProcessKiller.dll"</InputAssemblies>
       <InputAssemblies>$(InputAssemblies) "$(OutDir)log4net.dll"</InputAssemblies>
-      <OutputAssembly>"$(OutDir)WinSW.exe"</OutputAssembly>
+      <OutputAssembly>"$(ArtifactsDir)WinSW.$(IdentifierSuffix).exe"</OutputAssembly>
     </PropertyGroup>
 
     <PropertyGroup Condition="'$(TargetFramework)' == 'net20' or '$(TargetFramework)' == 'net40'">
@@ -80,6 +106,7 @@
       <ILMergeCommand>"$(ILMerge)" $(ILMergeArgs)</ILMergeCommand>
     </PropertyGroup>
 
+    <MakeDir Directories="$(ArtifactsDir)" />
     <Message Text="$(ILMergeCommand)" Importance="high" />
     <Exec Command="$(ILMergeCommand)" />