Fix VersionSuffix for the managed projects
authorEric Erhardt <eric.erhardt@microsoft.com>
Wed, 7 Jun 2017 03:08:22 +0000 (22:08 -0500)
committerEric Erhardt <eric.erhardt@microsoft.com>
Mon, 25 Sep 2017 18:37:31 +0000 (13:37 -0500)
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 https://github.com/NuGet/Home/issues/4337

Commit migrated from https://github.com/dotnet/core-setup/commit/df6ab9c2a48b47181bedfb2704888b074e8a269a

src/installer/BranchInfo.props [new file with mode: 0644]
src/installer/build.proj
src/installer/managed/CommonManaged.props
src/installer/pkg/packaging/dir.proj
src/installer/restore.proj [deleted file]

diff --git a/src/installer/BranchInfo.props b/src/installer/BranchInfo.props
new file mode 100644 (file)
index 0000000..fa72178
--- /dev/null
@@ -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>
index 0cadd7b..bc22de9 100644 (file)
@@ -17,7 +17,6 @@
       CreateOrUpdateCurrentVersionFile;
       CreateVersionInfoFile;
       BatchRestorePackages;
-      ValidateExactRestore;
       BuildCustomTasks;
     </TraversalBuildDependencies>
     <TraversalBuildDependsOn>
   </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://github.com/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" />
index 0c54133..341b2af 100644 (file)
@@ -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>
     <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://github.com/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>
@@ -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>
\ No newline at end of file
index 9102701..bebdb48 100644 (file)
     <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>
 
diff --git a/src/installer/restore.proj b/src/installer/restore.proj
deleted file mode 100644 (file)
index ae55b08..0000000
+++ /dev/null
@@ -1,10 +0,0 @@
-<?xml version="1.0" encoding="utf-8"?>
-<Project ToolsVersion="12.0" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
-  <Import Project="dir.props" />
-
-  <Target Name="Build">
-    <Message Importance="High" Text="Restoring all packages..." />
-    <Exec Condition="'@(SdkRestoreProjects)' != ''" Command="$(DotnetRestoreCommand) &quot;%(SdkRestoreProjects.FullPath)&quot; %(SdkRestoreProjects.ExtraRestoreArgs)" StandardOutputImportance="Low" />
-  </Target>
-
-</Project>