diff options
| author | Rob Mensching <rob@firegiant.com> | 2021-04-16 23:35:06 -0700 |
|---|---|---|
| committer | Rob Mensching <rob@firegiant.com> | 2021-04-29 16:47:06 -0700 |
| commit | a2f0de28fc0f1ab71d4685c77f0b21d946f3e702 (patch) | |
| tree | 585a60388d844515a21b5d8a786e5f91ff227127 /src/Directory.Build.targets | |
| parent | ae224f38e8349e2d0dfce95918571db4f18b5fba (diff) | |
| download | wix-a2f0de28fc0f1ab71d4685c77f0b21d946f3e702.tar.gz wix-a2f0de28fc0f1ab71d4685c77f0b21d946f3e702.tar.bz2 wix-a2f0de28fc0f1ab71d4685c77f0b21d946f3e702.zip | |
Introduce new versioning system based on GitInfo
Diffstat (limited to 'src/Directory.Build.targets')
| -rw-r--r-- | src/Directory.Build.targets | 120 |
1 files changed, 89 insertions, 31 deletions
diff --git a/src/Directory.Build.targets b/src/Directory.Build.targets index 2fcc765a..c426f25e 100644 --- a/src/Directory.Build.targets +++ b/src/Directory.Build.targets | |||
| @@ -4,47 +4,105 @@ | |||
| 4 | Do NOT modify this file. Update the canonical version in Home\repo-template\src\Directory.Build.targets | 4 | Do NOT modify this file. Update the canonical version in Home\repo-template\src\Directory.Build.targets |
| 5 | then update all of the repos. | 5 | then update all of the repos. |
| 6 | --> | 6 | --> |
| 7 | <!-- | ||
| 8 | Replace PackageReferences with ProjectReferences when the projects can be found in .sln. | ||
| 9 | See the original here: https://github.com/dotnet/sdk/issues/1151#issuecomment-385133284 | ||
| 10 | --> | ||
| 11 | <Project> | 7 | <Project> |
| 12 | <PropertyGroup> | 8 | <PropertyGroup> |
| 13 | <ReplacePackageReferences>true</ReplacePackageReferences> | 9 | <SigningToolFolder>$(BaseOutputPath)obj\.tools</SigningToolFolder> |
| 14 | <TheSolutionPath Condition=" '$(NCrunch)'=='' ">$(SolutionPath)</TheSolutionPath> | 10 | <SigningToolExe>$(SigningToolFolder)\SignClient.exe</SigningToolExe> |
| 15 | <TheSolutionPath Condition=" '$(NCrunch)'=='1' ">$(NCrunchOriginalSolutionPath)</TheSolutionPath> | 11 | <SigningFilelist>$(SigningToolFolder)\empty-filelist.txt</SigningFilelist> |
| 12 | <SigningConfiguration>$([MSBuild]::GetDirectoryNameOfFileAbove($(MSBuildProjectDirectory), signing.json))\signing.json</SigningConfiguration> | ||
| 13 | </PropertyGroup> | ||
| 14 | |||
| 15 | <Target Name="__FixupGitBaseVersion" BeforeTargets="_GitPopulateVersionInfo"> | ||
| 16 | <PropertyGroup> | ||
| 17 | <GitBaseVersion>$(GitBaseVersion.Replace('{apiversion}', '$(ApiVersion)'))</GitBaseVersion> | ||
| 18 | <GitBaseVersion>$(GitBaseVersion.Replace('{height}', '$(GitCommits)'))</GitBaseVersion> | ||
| 19 | <GitBaseVersion>$(GitBaseVersion.Replace('{commits}', '$(GitCommits)'))</GitBaseVersion> | ||
| 20 | </PropertyGroup> | ||
| 21 | </Target> | ||
| 22 | |||
| 23 | <Target Name="__SetPropertiesFromGit" DependsOnTargets="GitVersion"> | ||
| 24 | <PropertyGroup> | ||
| 25 | <AssemblyVersion>$(GitBaseVersionMajor).$(GitBaseVersionMinor).0.0</AssemblyVersion> | ||
| 26 | <FileVersion>$(GitBaseVersionMajor).$(GitBaseVersionMinor).$(GitBaseVersionPatch).$(GitCommits)</FileVersion> | ||
| 27 | <PackageVersion>$(GitBaseVersionMajor).$(GitBaseVersionMinor).$(GitBaseVersionPatch)$(GitSemVerDashLabel)</PackageVersion> | ||
| 28 | <InformationalVersion>$(GitBaseVersionMajor).$(GitBaseVersionMinor).$(GitBaseVersionPatch)$(GitSemVerDashLabel)+$(GitSha)</InformationalVersion> | ||
| 29 | <!-- We already included the $(GitSha) in the informational version so do not include it again. --> | ||
| 30 | <IncludeSourceRevisionInInformationalVersion>false</IncludeSourceRevisionInInformationalVersion> | ||
| 31 | </PropertyGroup> | ||
| 32 | |||
| 33 | <Message Importance="$(GitInfoReportImportance)" Text="Properties from Git: | ||
| 34 | GitCommits: $(GitCommits) | ||
| 35 | AssemblyVersion: $(AssemblyVersion) | ||
| 36 | FileVersion: $(FileVersion) | ||
| 37 | InformationalVersion: $(InformationalVersion) | ||
| 38 | PackageVersion: $(PackageVersion) | ||
| 39 | " /> | ||
| 40 | </Target> | ||
| 41 | |||
| 42 | <PropertyGroup> | ||
| 43 | <GenerateNuspecDependsOn> | ||
| 44 | $(GenerateNuspecDependsOn); | ||
| 45 | __SetNuspecProperties | ||
| 46 | </GenerateNuspecDependsOn> | ||
| 16 | </PropertyGroup> | 47 | </PropertyGroup> |
| 17 | 48 | ||
| 18 | <Choose> | 49 | <Target Name="__SetNuspecProperties" DependsOnTargets="__SetPropertiesFromGit" |
| 19 | <When Condition="$(ReplacePackageReferences) AND '$(TheSolutionPath)' != '' AND '$(TheSolutionPath)' != '*undefined*' AND Exists('$(TheSolutionPath)')"> | 50 | Condition=" Exists('$(MSBuildProjectName).nuspec') "> |
| 51 | <PropertyGroup> | ||
| 52 | <ProjectUrl Condition=" '$(ProjectUrl)'=='' and '$(GitRepositoryUrl)'!='' ">$(GitRepositoryUrl.Replace('.git',''))</ProjectUrl> | ||
| 53 | |||
| 54 | <NuspecFile>$(MSBuildProjectName).nuspec</NuspecFile> | ||
| 55 | <NuspecBasePath Condition=" '$(NuspecBasePath)'=='' ">$([System.IO.Path]::GetFullPath($(OutputPath)..))\</NuspecBasePath> | ||
| 56 | <NuspecProperties>$(NuspecProperties);Id=$(PackageId);Authors="$(Authors)";Configuration=$(Configuration);Copyright="$(Copyright)";Description="$(Description)";Title="$(Title)"</NuspecProperties> | ||
| 57 | <NuspecProperties>$(NuspecProperties);Version=$(PackageVersion);RepositoryCommit=$(GitSha);RepositoryType=git;RepositoryUrl=$(GitRepositoryUrl);ProjectFolder=$(MSBuildProjectDirectory)\;ProjectUrl=$(ProjectUrl)</NuspecProperties> | ||
| 58 | <PublishRepositoryUrl>true</PublishRepositoryUrl> | ||
| 59 | <SymbolPackageFormat>snupkg</SymbolPackageFormat> | ||
| 60 | </PropertyGroup> | ||
| 61 | |||
| 62 | <Message Importance="$(GitInfoReportImportance)" Text="NuSpec info: | ||
| 63 | NuspecFile: $(NuspecFile) | ||
| 64 | NuspecBasePath: $(NuspecBasePath) | ||
| 65 | NuspecProperties: $(NuspecProperties) | ||
| 66 | " /> | ||
| 67 | |||
| 68 | </Target> | ||
| 69 | |||
| 70 | <Target Name="PackNative" DependsOnTargets="__SetNuspecProperties" | ||
| 71 | Condition=" Exists('$(MSBuildProjectName).nuspec') "> | ||
| 72 | |||
| 73 | <Exec Command='nuget pack $(NuspecFile) -OutputDirectory "$(BaseOutputPath)$(Configuration)" -BasePath "$(NuspecBasePath)" -Properties $(NuspecProperties)' | ||
| 74 | WorkingDirectory="$(MSBuildProjectDirectory)" /> | ||
| 75 | |||
| 76 | <ItemGroup> | ||
| 77 | <NuGetPackOutput Include="$(BaseOutputPath)$(Configuration)\**\$(PackageId)*.nupkg" /> | ||
| 78 | </ItemGroup> | ||
| 79 | </Target> | ||
| 80 | |||
| 81 | <Target Name="_GetSignClient" | ||
| 82 | Condition=" !Exists('$(SigningToolExe)') "> | ||
| 20 | 83 | ||
| 21 | <PropertyGroup> | 84 | <WriteLinesToFile File='$(SigningFilelist)' Lines='do-not-sign-files-in-nupkg' Overwrite='true' /> |
| 22 | <SolutionFileContent>$([System.IO.File]::ReadAllText($(TheSolutionPath)))</SolutionFileContent> | ||
| 23 | <SmartSolutionDir>$([System.IO.Path]::GetDirectoryName( $(TheSolutionPath) ))</SmartSolutionDir> | ||
| 24 | <RegexPattern>(?<="[PackageName]", ")(.*)(?=", ")</RegexPattern> | ||
| 25 | </PropertyGroup> | ||
| 26 | 85 | ||
| 27 | <ItemGroup> | 86 | <Exec Command='dotnet.exe tool install --tool-path "$(SigningToolFolder)" SignClient' /> |
| 28 | <!-- Keep the identity of the PackageReference --> | 87 | </Target> |
| 29 | <SmartPackageReference Include="@(PackageReference)"> | ||
| 30 | <PackageName>%(Identity)</PackageName> | ||
| 31 | <InSolution>$(SolutionFileContent.Contains('\%(Identity).csproj'))</InSolution> | ||
| 32 | </SmartPackageReference> | ||
| 33 | 88 | ||
| 34 | <!-- Filter them by mapping them to another ItemGroup using the WithMetadataValue item function --> | 89 | <Target Name="SignOutput" DependsOnTargets="_GetSignClient" AfterTargets="AfterBuild" |
| 35 | <PackageInSolution Include="@(SmartPackageReference->WithMetadataValue('InSolution', True))"> | 90 | Condition=" '$(SigningUser)'!='' and '$(SignOutput)'!='false' and |
| 36 | <Pattern>$(RegexPattern.Replace('[PackageName]','%(PackageName)') )</Pattern> | 91 | ('$(MSBuildProjectExtension)'=='.csproj' or ('$(MSBuildProjectExtension)'=='.vcxproj' and '$(ConfigurationType)'!='StaticLibrary'))"> |
| 37 | <SmartPath>$([System.Text.RegularExpressions.Regex]::Match('$(SolutionFileContent)', '%(Pattern)'))</SmartPath> | ||
| 38 | </PackageInSolution> | ||
| 39 | 92 | ||
| 40 | <ProjectReference Include="@(PackageInSolution->'$(SmartSolutionDir)\%(SmartPath)' )"/> | 93 | <Exec Command='"$(SigningToolExe)" sign -i $(TargetPath) -c "$(SigningConfiguration)" -n "WiX Toolset" -d "WiX Toolset" -u https://wixtoolset.org/ -r "$(SigningUser)" -s "$(SigningSecret)"' |
| 94 | WorkingDirectory="$(MSBuildProjectDirectory)" EchoOff="true" /> | ||
| 95 | </Target> | ||
| 41 | 96 | ||
| 42 | <!-- Remove the package references that are now referenced as projects --> | 97 | <Target Name="SignNupkg" DependsOnTargets="_GetSignClient" AfterTargets="Pack;PackNative" |
| 43 | <PackageReference Remove="@(PackageInSolution->'%(PackageName)')"/> | 98 | Condition=" '$(SigningUser)'!='' and '@(NuGetPackOutput)'!='' and '$(SignNupkg)'!='false' "> |
| 44 | </ItemGroup> | 99 | <ItemGroup> |
| 100 | <SigningNupkgs Include="@(NuGetPackOutput)" Condition=" '%(Extension)'=='.nupkg' " /> | ||
| 101 | </ItemGroup> | ||
| 45 | 102 | ||
| 46 | </When> | 103 | <Exec Command='"$(SigningToolExe)" sign -i "@(SigningNupkgs->'%(Identity)')" -c "$(SigningConfiguration)" -f "$(SigningFilelist)" -n "WiX Toolset" -d "WiX Toolset" -u https://wixtoolset.org/ -r "$(SigningUser)" -s "$(SigningSecret)"' |
| 47 | </Choose> | 104 | WorkingDirectory="$(MSBuildProjectDirectory)" EchoOff="true" /> |
| 105 | </Target> | ||
| 48 | 106 | ||
| 49 | <Import Project="Directory$(MSBuildProjectExtension).targets" Condition=" Exists('Directory$(MSBuildProjectExtension).targets') " /> | 107 | <Import Project="Directory$(MSBuildProjectExtension).targets" Condition=" Exists('Directory$(MSBuildProjectExtension).targets') " /> |
| 50 | <Import Project="Custom.Build.targets" Condition=" Exists('Custom.Build.targets') " /> | 108 | <Import Project="Custom.Build.targets" Condition=" Exists('Custom.Build.targets') " /> |
