Skip to content

Commit

Permalink
Fix VersionSuffix for the managed projects
Browse files Browse the repository at this point in the history
VersionSuffix is getting set before $(BuildNumberMajor) and $(BuildNumberMinor) are being set.  When creating the DependencyModel nupkg, it is getting a bad version on its p2p reference to PlatformAbstractions.

The fix is to ensure VersionSuffix is defined correctly in the projects themselves - after the obj\BuildVersion.props file is created.

Workaround NuGet/Home#4337
  • Loading branch information
eerhardt committed Sep 25, 2017
1 parent bb6dac8 commit df6ab9c
Show file tree
Hide file tree
Showing 6 changed files with 53 additions and 48 deletions.
13 changes: 13 additions & 0 deletions BranchInfo.props
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
<Project ToolsVersion="12.0" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<PropertyGroup>
<MajorVersion>2</MajorVersion>
<MinorVersion>0</MinorVersion>
<PatchVersion>2</PatchVersion>
<StabilizePackageVersion Condition="'$(StabilizePackageVersion)' == ''">false</StabilizePackageVersion>
<PreReleaseLabel>servicing</PreReleaseLabel>
<ReleaseSuffix>$(PreReleaseLabel)</ReleaseSuffix>
<ReleaseBrandSuffix></ReleaseBrandSuffix>
<Channel>release/2.0.0</Channel>
<BranchName>release/2.0.0</BranchName>
</PropertyGroup>
</Project>
19 changes: 2 additions & 17 deletions build.proj
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,6 @@
CreateOrUpdateCurrentVersionFile;
CreateVersionInfoFile;
BatchRestorePackages;
ValidateExactRestore;
BuildCustomTasks;
</TraversalBuildDependencies>
<TraversalBuildDependsOn>
Expand Down Expand Up @@ -59,22 +58,8 @@
</Target>

<Target Name="BatchRestorePackages" Condition="'$(RestoreDuringBuild)'=='true'">
<!-- Restore packages in a separate msbuild instance so that the buildversion props file generated in
CreateVersionInfoFile target gets evaluated, this ensures VersionSuffix is set (especially during
'dotnet restore') to work around https:/NuGet/Home/issues/4337 -->
<MSBuild Projects="$(MSBuildThisFileDirectory)restore.proj" />
</Target>

<!-- Task from buildtools that uses lockfiles to validate that packages restored are exactly what were specified. -->
<UsingTask TaskName="ValidateExactRestore" AssemblyFile="$(BuildToolsTaskDir)Microsoft.DotNet.Build.Tasks.dll" />

<Target Name="ValidateExactRestore"
Condition="'$(AllowInexactRestore)'!='true'">
<ItemGroup>
<ProjectJsonTemplateFiles Include="$(MSBuildThisFileDirectory)**\project.json.template" />
<ProjectJsonsExcludingTemplateFiles Include="@(ProjectJsonFiles)" Exclude="@(ProjectJsonTemplateFiles)" />
</ItemGroup>
<ValidateExactRestore ProjectLockJsons="@(ProjectJsonsExcludingTemplateFiles->'%(RootDir)%(Directory)%(Filename).lock.json')" />
<Message Importance="High" Text="Restoring all packages..." />
<Exec Condition="'@(SdkRestoreProjects)' != ''" Command="$(DotnetRestoreCommand) &quot;%(SdkRestoreProjects.FullPath)&quot;" StandardOutputImportance="Low" />
</Target>

<Import Project="dir.targets" />
Expand Down
20 changes: 3 additions & 17 deletions dir.props
Original file line number Diff line number Diff line change
Expand Up @@ -9,19 +9,8 @@
<PortableBuild Condition="'$(PortableBuild)' == ''">true</PortableBuild>
</PropertyGroup>

<!-- Branch Info -->
<PropertyGroup>
<MajorVersion>2</MajorVersion>
<MinorVersion>0</MinorVersion>
<PatchVersion>2</PatchVersion>
<StabilizePackageVersion Condition="'$(StabilizePackageVersion)' == ''">false</StabilizePackageVersion>
<PreReleaseLabel>servicing</PreReleaseLabel>
<ReleaseSuffix>$(PreReleaseLabel)</ReleaseSuffix>
<ReleaseBrandSuffix></ReleaseBrandSuffix>
<Channel>release/2.0.0</Channel>
<BranchName>release/2.0.0</BranchName>
</PropertyGroup>

<Import Project="$(MSBuildThisFileDirectory)BranchInfo.props" />

<PropertyGroup>
<SharedFrameworkName>Microsoft.NETCore.App</SharedFrameworkName>
</PropertyGroup>
Expand Down Expand Up @@ -139,10 +128,7 @@
<ItemGroup>
<SdkRestoreProjects Include="$(MSBuildThisFileDirectory)src\pkg\deps\deps.csproj" />
<SdkRestoreProjects Include="$(MSBuildThisFileDirectory)src\managed\Microsoft.DotNet.PlatformAbstractions\Microsoft.DotNet.PlatformAbstractions.csproj" />
<SdkRestoreProjects Include="$(MSBuildThisFileDirectory)src\managed\Microsoft.Extensions.DependencyModel\Microsoft.Extensions.DependencyModel.csproj">
<!-- Workaround https:/NuGet/Home/issues/4337 -->
<ExtraRestoreArgs>/p:VersionSuffix=$(VersionSuffix)</ExtraRestoreArgs>
</SdkRestoreProjects>
<SdkRestoreProjects Include="$(MSBuildThisFileDirectory)src\managed\Microsoft.Extensions.DependencyModel\Microsoft.Extensions.DependencyModel.csproj" />
</ItemGroup>
<PropertyGroup>
<DotnetRestorePrefix Condition="'$(RunningOnUnix)' == 'true'">DOTNET_SKIP_FIRST_TIME_EXPERIENCE=1 </DotnetRestorePrefix>
Expand Down
10 changes: 0 additions & 10 deletions restore.proj

This file was deleted.

36 changes: 34 additions & 2 deletions src/managed/CommonManaged.props
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,24 @@

<PropertyGroup>
<RepoRoot>$([System.IO.Path]::GetFullPath('$(MSBuildThisFileDirectory)../..'))/</RepoRoot>
<VersionPrefix>2.0.2</VersionPrefix>
</PropertyGroup>

<Import Project="$(RepoRoot)BranchInfo.props" />

<PropertyGroup>
<!-- Output directories -->
<BinDir Condition="'$(BinDir)'==''">$(RepoRoot)Bin/</BinDir>
<ObjDir Condition="'$(ObjDir)'==''">$(BinDir)obj/</ObjDir>

<!-- BuildVersion Properties -->
<TodayTimeStamp>$([System.DateTime]::Now.ToString(yyyyMMdd))</TodayTimeStamp>
<BuildVersionFile Condition="'$(BuildVersionFile)'==''">$(ObjDir)BuildVersion-$(TodayTimeStamp).props</BuildVersionFile>
</PropertyGroup>

<Import Project="$(BuildVersionFile)" />

<PropertyGroup>
<VersionPrefix>$(MajorVersion).$(MinorVersion).$(PatchVersion)</VersionPrefix>
<AssemblyFileVersion>$(VersionPrefix)</AssemblyFileVersion>
<TreatWarningsAsErrors>true</TreatWarningsAsErrors>
<DisableImplicitFrameworkReferences>true</DisableImplicitFrameworkReferences>
Expand All @@ -17,6 +34,21 @@
<PackageThirdPartyNoticesFile>$(RepoRoot)THIRD-PARTY-NOTICES.TXT</PackageThirdPartyNoticesFile>
</PropertyGroup>

<PropertyGroup Condition="'$(StabilizePackageVersion)' != 'true'">
<!-- Dev builds get a minor version, by default, of '0'. Our tests restore packages with
a -* version, and include myget sources, so any package published the same day to myget
will conflict with the local build and override the local built package. Prevent this
by setting the non-official build minor version to 9 -->
<BuildNumberMinor Condition="'$(BuildNumberMinor)' == '0'">9</BuildNumberMinor>

<!--
Ensure VersionSuffix is always set (especially during 'dotnet restore')
to work around https:/NuGet/Home/issues/4337
-->
<VersionSuffix Condition="'$(PreReleaseLabel)' != ''">$(PreReleaseLabel)-</VersionSuffix>
<VersionSuffix>$(VersionSuffix)$(BuildNumberMajor)-$(BuildNumberMinor)</VersionSuffix>
</PropertyGroup>

<PropertyGroup>
<AssemblyOriginatorKeyFile>$(RepoRoot)tools-local/setuptools/Key.snk</AssemblyOriginatorKeyFile>
<SignAssembly>true</SignAssembly>
Expand Down Expand Up @@ -45,5 +77,5 @@
</Content>
</ItemGroup>

<Import Condition="Exists('$(RepoRoot)Tools/versioning.props')" Project="$(RepoRoot)Tools/versioning.props" />
<Import Condition="Exists('$(RepoRoot)Tools/versioning.props')" Project="$(RepoRoot)Tools/versioning.props" />
</Project>
3 changes: 1 addition & 2 deletions src/pkg/packaging/dir.proj
Original file line number Diff line number Diff line change
Expand Up @@ -183,10 +183,9 @@
<PropertyGroup>
<OutputArg>--output $(PackagesOutDir)</OutputArg>
<ConfigArg>--configuration $(ConfigurationGroup)</ConfigArg>
<VersionSuffixArg Condition="'$(VersionSuffix)' != ''">--version-suffix $(VersionSuffix)</VersionSuffixArg>
</PropertyGroup>

<Exec Command="$(DotnetToolCommand) pack %(PackageProjects.Identity) --no-build $(OutputArg) $(ConfigArg) $(VersionSuffixArg) /p:BaseOutputPath=$(IntermediateOutputForPackaging)"
<Exec Command="$(DotnetToolCommand) pack %(PackageProjects.Identity) --no-build $(OutputArg) $(ConfigArg) /p:BaseOutputPath=$(IntermediateOutputForPackaging)"
Condition="'@(PackageProjects)' != ''" />
</Target>

Expand Down

0 comments on commit df6ab9c

Please sign in to comment.