Skip to content

Commit

Permalink
[release/6.0] Tweak workload build to use _GenerateMsiVersionString t…
Browse files Browse the repository at this point in the history
…arget (#60695)

* Tweak workload build to use _GenerateMsiVersionString target

Replaces GenerateVersions that wasn't quite accurate enough for what we need

* Pulled in arcade target that will be removed at a later date

* More tweaks

* Forget dependsontargets

Co-authored-by: Steve Pfister <steve.pfister@microsoft.com>
  • Loading branch information
github-actions[bot] and Steve Pfister committed Oct 20, 2021
1 parent c86a857 commit 6f41165
Showing 1 changed file with 30 additions and 28 deletions.
58 changes: 30 additions & 28 deletions src/workloads/workloads.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@

<Import Sdk="Microsoft.NET.Sdk" Project="Sdk.targets" />

<Target Name="Build" DependsOnTargets="GenerateVersions">
<Target Name="Build" DependsOnTargets="GetAssemblyVersion;_GetVersionProps;_GenerateMsiVersionString">
<ItemGroup>
<!-- Overrides for Visual Studio setup generation. If the workload definition IDs change,
these must be updated. -->
Expand Down Expand Up @@ -94,14 +94,6 @@
<ManifestPackages Include="$(PackageSource)Microsoft.NET.Workload.Mono.ToolChain.Manifest-*.nupkg" />
</ItemGroup>

<GenerateMsiVersion
Major="$([System.Version]::Parse('$(SDKBundleVersion)').Major)"
Minor="$([System.Version]::Parse('$(SDKBundleVersion)').Minor)"
Patch="$([System.Version]::Parse('$(SDKBundleVersion)').Build)"
BuildNumber="$([System.Version]::Parse('$(SDKBundleVersion)').Revision)" >
<Output TaskParameter="MsiVersion" PropertyName="MsiVersion" />
</GenerateMsiVersion>

<GenerateManifestMsi
IntermediateBaseOutputPath="$(IntermediateOutputPath)"
OutputPath="$(OutputPath)"
Expand Down Expand Up @@ -183,28 +175,38 @@
<MSBuild Projects="@(VisualStudioManifestProjects)" BuildInParallel="true" Properties="SwixBuildTargets=$(SwixBuildTargets);ManifestOutputPath=$(VersionedVisualStudioSetupInsertionPath);OutputPath=$(VersionedVisualStudioSetupInsertionPath)" />
</Target>

<Target Name="GenerateVersions" DependsOnTargets="GetAssemblyVersion">
<Exec Command="git rev-list --count HEAD"
ConsoleToMSBuild="true"
Condition=" '$(GitCommitCount)' == '' ">
<Output TaskParameter="ConsoleOutput" PropertyName="GitCommitCount" />
</Exec>

<Error Condition=" '$(OfficialBuild)' == 'true' And '$(_PatchNumber)' == '' "
Text="_PatchNumber should not be empty in an official build. Check if there were changes in Arcade." />
<Target Name="_GetVersionProps">
<PropertyGroup>
<_MajorVersion>$([System.Version]::Parse('$(AssemblyVersion)').Major)</_MajorVersion>
<_MinorVersion>$([System.Version]::Parse('$(AssemblyVersion)').Minor)</_MinorVersion>
<_PatchVersion>$([System.Version]::Parse('$(AssemblyVersion)').Build)</_PatchVersion>
<_BuildNumber>$([System.Version]::Parse('$(AssemblyVersion)').Revision)</_BuildNumber>
</PropertyGroup>
</Target>

<Target Name="_GenerateMsiVersionString">
<PropertyGroup>
<GitCommitCount>$(GitCommitCount.PadLeft(6,'0'))</GitCommitCount>
<VersionPadding Condition="'$(VersionPadding)'==''">5</VersionPadding>
<!-- Using the following default comparison date will produce versions that align with our internal build system. -->
<VersionComparisonDate Condition="'$(VersionComparisonDate)'==''">1996-04-01</VersionComparisonDate>
</PropertyGroup>

<!-- This number comes from arcade and combines the date based build number id and the revision (incremental number per day) -->
<CombinedBuildNumberAndRevision>$(_PatchNumber)</CombinedBuildNumberAndRevision>
<!-- Fallback to commit count when patch number is not set. This happens only during CI. -->
<CombinedBuildNumberAndRevision Condition=" '$(CombinedBuildNumberAndRevision)' == '' ">$(GitCommitCount)</CombinedBuildNumberAndRevision>
<GenerateCurrentVersion
SeedDate="$([System.DateTime]::Now.ToString(yyyy-MM-dd))"
OfficialBuildId="$(OfficialBuildId)"
ComparisonDate="$(VersionComparisonDate)"
Padding="$(VersionPadding)">
<Output PropertyName="BuildNumberMajor" TaskParameter="GeneratedVersion" />
<Output PropertyName="BuildNumberMinor" TaskParameter="GeneratedRevision" />
</GenerateCurrentVersion>

<!-- This number comes from arcade and combines the date based build number id and the revision (incremental number per day) -->
<SDKBundleVersion>$(FileVersion)</SDKBundleVersion>
<!-- Fallback to commit count when patch number is not set. This happens only during CI. -->
<SDKBundleVersion Condition=" '$(SDKBundleVersion)' == '' ">$(VersionPrefix).$(CombinedBuildNumberAndRevision)</SDKBundleVersion>
</PropertyGroup>
<GenerateMsiVersion
Major="$(_MajorVersion)"
Minor="$(_MinorVersion)"
Patch="$(_PatchVersion)"
BuildNumberMajor="$(BuildNumberMajor)"
BuildNumberMinor="$(BuildNumberMinor)">
<Output TaskParameter="MsiVersion" PropertyName="MsiVersion" />
</GenerateMsiVersion>
</Target>
</Project>

0 comments on commit 6f41165

Please sign in to comment.