From 4abb4d97a914ba7c09359c3dbdd7f6f4dbf270ba Mon Sep 17 00:00:00 2001 From: Nick Guerrera Date: Tue, 21 Mar 2017 20:21:34 -0700 Subject: [PATCH 1/6] Update dotnet/sdk version --- build/DependencyVersions.props | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/build/DependencyVersions.props b/build/DependencyVersions.props index d2c6eedfe..dfacb08a6 100644 --- a/build/DependencyVersions.props +++ b/build/DependencyVersions.props @@ -4,7 +4,7 @@ 2.0.0-beta-001791-00 15.2.0-preview-000047-02 2.0.0-rc4-61325-08 - 2.0.0-alpha-20170320-1 + 2.0.0-alpha-20170322-1 4.3.0-beta1-2342 1.0.0-alpha-20170130-3-281 15.1.0-preview-20170316-05 From a5051a0aff5b402cc9a3cddef280ca5d0256babc Mon Sep 17 00:00:00 2001 From: Nick Guerrera Date: Tue, 21 Mar 2017 19:02:20 -0700 Subject: [PATCH 2/6] Generate bundled version props --- build/BundledVersions.targets | 67 +++++++++++++++++++++++++++++++++++ src/redist/redist.csproj | 1 + 2 files changed, 68 insertions(+) create mode 100644 build/BundledVersions.targets diff --git a/build/BundledVersions.targets b/build/BundledVersions.targets new file mode 100644 index 000000000..065eefe96 --- /dev/null +++ b/build/BundledVersions.targets @@ -0,0 +1,67 @@ + + + $(IntermediateDirectory)/GeneratedMSBuildImports + 15.0/Imports/Microsoft.Common.props/ImportBefore + Microsoft.NETCoreSdk.BundledVersions.props + + + + + + + <_NETStandardLibraryVersions Include="@(PackageDefinitions->'%(Version)')" + Condition="%(PackageDefinitions.Name) == 'NetStandard.Library'" /> + + + + + + <_NETCoreAppPackageVersion>$(CLI_SharedFrameworkVersion) + <_NETStandardPackageVersion>@(_NETStandardLibraryVersions->Distinct()) + + + <_NETCoreAppTargetFrameworkVersion>$(_NETCoreAppPackageVersion.Split('.')[0]).$(_NETCoreAppPackageVersion.Split('.')[1]) + <_NETStandardTargetFrameworkVersion>$(_NETStandardPackageVersion.Split('.')[0]).$(_NETStandardPackageVersion.Split('.')[1]) + + + + + + $(_NETCoreAppTargetFrameworkVersion) + $(_NETCoreAppPackageVersion) + $(_NETStandardTargetFrameworkVersion) + $(_NETStandardPackageVersion) + + +]]> + + + + + + + + + + + + diff --git a/src/redist/redist.csproj b/src/redist/redist.csproj index 7c7ef6569..5bf539615 100644 --- a/src/redist/redist.csproj +++ b/src/redist/redist.csproj @@ -2,6 +2,7 @@ + $(CliVersionPrefix) From b4e21df4248c0248885ac5e9a93ab6c846f918af Mon Sep 17 00:00:00 2001 From: Nick Guerrera Date: Thu, 23 Mar 2017 11:21:39 -0700 Subject: [PATCH 3/6] Add test coverage for bundled version props --- .../dotnet-new.Tests/GivenThatIWantANewApp.cs | 82 +++++++++++++++---- 1 file changed, 66 insertions(+), 16 deletions(-) diff --git a/test/dotnet-new.Tests/GivenThatIWantANewApp.cs b/test/dotnet-new.Tests/GivenThatIWantANewApp.cs index 649fa62ff..09454669b 100644 --- a/test/dotnet-new.Tests/GivenThatIWantANewApp.cs +++ b/test/dotnet-new.Tests/GivenThatIWantANewApp.cs @@ -7,6 +7,7 @@ using System.Linq; using System.Xml.Linq; using FluentAssertions; using Microsoft.DotNet.Tools.Test.Utilities; +using Microsoft.Extensions.DependencyModel; using Xunit; namespace Microsoft.DotNet.New.Tests @@ -70,36 +71,85 @@ namespace Microsoft.DotNet.New.Tests .Should().Pass(); } - [Fact] - public void NewClassLibRestoresCorrectNetStandardLibraryVersion() + [Theory] + [InlineData("console", "RuntimeFrameworkVersion", "Microsoft.NETCore.App")] + [InlineData("classlib", "NetStandardImplicitPackageVersion", "NETStandard.Library")] + public void NewProjectRestoresCorrectPackageVersion(string type, string propertyName, string packageName) { - var rootPath = TestAssets.CreateTestDirectory().FullName; + // These will fail when templates stop including explicit version. + // Collapse back to one method and remove the explicit version handling when that happens. + NewProjectRestoresCorrectPackageVersion(type, propertyName, packageName, deleteExplicitVersion: true); + NewProjectRestoresCorrectPackageVersion(type, propertyName, packageName, deleteExplicitVersion: false); + } + + private void NewProjectRestoresCorrectPackageVersion(string type, string propertyName, string packageName, bool deleteExplicitVersion) + { + var rootPath = TestAssets.CreateTestDirectory(identifier: $"_{type}_{deleteExplicitVersion}").FullName; var packagesDirectory = Path.Combine(rootPath, "packages"); - var projectName = "Library"; - var projectFileName = $"{projectName}.csproj"; + var projectName = "Project"; + var expectedVersion = GetFrameworkPackageVersion(); new NewCommand() .WithWorkingDirectory(rootPath) - .Execute($"classlib --name {projectName} -o .") + .Execute($"{type} --name {projectName} -o .") .Should().Pass(); + ValidateAndRemoveExplicitVersion(); + new RestoreCommand() .WithWorkingDirectory(rootPath) .Execute($"--packages {packagesDirectory}") .Should().Pass(); - var expectedVersion = XDocument.Load(Path.Combine(rootPath, projectFileName)) - .Elements("Project") - .Elements("PropertyGroup") - .Elements("NetStandardImplicitPackageVersion") - .FirstOrDefault() - ?.Value; - - expectedVersion.Should().NotBeNullOrEmpty("Could not find NetStandardImplicitPackageVersion property in a new classlib."); - - new DirectoryInfo(Path.Combine(packagesDirectory, "netstandard.library")) + new DirectoryInfo(Path.Combine(packagesDirectory, packageName)) .Should().Exist() .And.HaveDirectory(expectedVersion); + + string GetFrameworkPackageVersion() + { + var dotnetDir = new FileInfo(DotnetUnderTest.FullName).Directory; + var sharedFxDir = dotnetDir + .GetDirectory("shared", "Microsoft.NETCore.App") + .EnumerateDirectories() + .Single(d => d.Name.StartsWith("2.0.0")); + + if (packageName == "Microsoft.NETCore.App") + { + return sharedFxDir.Name; + } + + var depsFile = Path.Combine(sharedFxDir.FullName, "Microsoft.NETCore.App.deps.json"); + using (var stream = File.OpenRead(depsFile)) + using (var reader = new DependencyContextJsonReader()) + { + var context = reader.Read(stream); + var dependency = context + .RuntimeLibraries + .Single(library => library.Name.Equals(packageName, StringComparison.OrdinalIgnoreCase)); + + return dependency.Version; + } + } + + // Remove when templates stop putting an explicit version + void ValidateAndRemoveExplicitVersion() + { + var projectFileName = $"{projectName}.csproj"; + var projectPath = Path.Combine(rootPath, projectFileName); + var projectDocument = XDocument.Load(projectPath); + var explicitVersionNode = projectDocument + .Elements("Project") + .Elements("PropertyGroup") + .Elements(propertyName) + .SingleOrDefault(); + + explicitVersionNode.Should().NotBeNull(); + if (deleteExplicitVersion) + { + explicitVersionNode.Remove(); + projectDocument.Save(projectPath); + } + } } } } From c00e84dd9be5f96038a9f16be167286e80be827a Mon Sep 17 00:00:00 2001 From: Nick Guerrera Date: Thu, 23 Mar 2017 12:54:07 -0700 Subject: [PATCH 4/6] Fix test issue vs. case sensitive file systems --- test/dotnet-new.Tests/GivenThatIWantANewApp.cs | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/test/dotnet-new.Tests/GivenThatIWantANewApp.cs b/test/dotnet-new.Tests/GivenThatIWantANewApp.cs index 09454669b..e95ff6644 100644 --- a/test/dotnet-new.Tests/GivenThatIWantANewApp.cs +++ b/test/dotnet-new.Tests/GivenThatIWantANewApp.cs @@ -72,8 +72,8 @@ namespace Microsoft.DotNet.New.Tests } [Theory] - [InlineData("console", "RuntimeFrameworkVersion", "Microsoft.NETCore.App")] - [InlineData("classlib", "NetStandardImplicitPackageVersion", "NETStandard.Library")] + [InlineData("console", "RuntimeFrameworkVersion", "microsoft.netcore.app")] + [InlineData("classlib", "NetStandardImplicitPackageVersion", "netstandard.library")] public void NewProjectRestoresCorrectPackageVersion(string type, string propertyName, string packageName) { // These will fail when templates stop including explicit version. @@ -113,7 +113,7 @@ namespace Microsoft.DotNet.New.Tests .EnumerateDirectories() .Single(d => d.Name.StartsWith("2.0.0")); - if (packageName == "Microsoft.NETCore.App") + if (packageName == "microsoft.netcore.app") { return sharedFxDir.Name; } @@ -125,7 +125,7 @@ namespace Microsoft.DotNet.New.Tests var context = reader.Read(stream); var dependency = context .RuntimeLibraries - .Single(library => library.Name.Equals(packageName, StringComparison.OrdinalIgnoreCase)); + .Single(library => library.Name == packageName); return dependency.Version; } From 15f171a5d77304fb5b11643c835b949fb90882b3 Mon Sep 17 00:00:00 2001 From: Nick Guerrera Date: Thu, 23 Mar 2017 13:16:54 -0700 Subject: [PATCH 5/6] Add back extra test check on value of explicit version --- test/dotnet-new.Tests/GivenThatIWantANewApp.cs | 2 ++ 1 file changed, 2 insertions(+) diff --git a/test/dotnet-new.Tests/GivenThatIWantANewApp.cs b/test/dotnet-new.Tests/GivenThatIWantANewApp.cs index e95ff6644..ac0610240 100644 --- a/test/dotnet-new.Tests/GivenThatIWantANewApp.cs +++ b/test/dotnet-new.Tests/GivenThatIWantANewApp.cs @@ -144,6 +144,8 @@ namespace Microsoft.DotNet.New.Tests .SingleOrDefault(); explicitVersionNode.Should().NotBeNull(); + explicitVersionNode.Value.Should().Be(expectedVersion); + if (deleteExplicitVersion) { explicitVersionNode.Remove(); From 815a33415e1515099b3e0059cbb1bc82614138a3 Mon Sep 17 00:00:00 2001 From: Nick Guerrera Date: Thu, 23 Mar 2017 14:21:04 -0700 Subject: [PATCH 6/6] Unpin stage0 --- run-build.ps1 | 4 ++-- run-build.sh | 4 ++-- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/run-build.ps1 b/run-build.ps1 index c02a924cf..ea77e8983 100644 --- a/run-build.ps1 +++ b/run-build.ps1 @@ -101,8 +101,8 @@ if ($LastExitCode -ne 0) # install the post-PJnistic stage0 $dotnetInstallPath = Join-Path $toolsLocalPath "dotnet-install.ps1" -Write-Host "$dotnetInstallPath -Channel ""master"" -Version ""2.0.0-preview1-005390"" -InstallDir $env:DOTNET_INSTALL_DIR -Architecture ""$Architecture""" -Invoke-Expression "$dotnetInstallPath -Channel ""master"" -Version ""2.0.0-preview1-005390"" -InstallDir $env:DOTNET_INSTALL_DIR -Architecture ""$Architecture""" +Write-Host "$dotnetInstallPath -Channel ""master"" -InstallDir $env:DOTNET_INSTALL_DIR -Architecture ""$Architecture""" +Invoke-Expression "$dotnetInstallPath -Channel ""master"" -InstallDir $env:DOTNET_INSTALL_DIR -Architecture ""$Architecture""" if ($LastExitCode -ne 0) { Write-Output "The .NET CLI installation failed with exit code $LastExitCode" diff --git a/run-build.sh b/run-build.sh index 684fb8049..17c515902 100755 --- a/run-build.sh +++ b/run-build.sh @@ -167,8 +167,8 @@ if [ $? != 0 ]; then fi # now execute the script -echo "installing CLI: $dotnetInstallPath --channel \"master\" --version \"2.0.0-preview1-005165\" --install-dir $DOTNET_INSTALL_DIR --architecture \"$ARCHITECTURE\" $LINUX_PORTABLE_INSTALL_ARGS" -$dotnetInstallPath --channel "master" --version "2.0.0-preview1-005390" --install-dir $DOTNET_INSTALL_DIR --architecture "$ARCHITECTURE" $LINUX_PORTABLE_INSTALL_ARGS +echo "installing CLI: $dotnetInstallPath --channel \"master\" --install-dir $DOTNET_INSTALL_DIR --architecture \"$ARCHITECTURE\" $LINUX_PORTABLE_INSTALL_ARGS" +$dotnetInstallPath --channel "master" --install-dir $DOTNET_INSTALL_DIR --architecture "$ARCHITECTURE" $LINUX_PORTABLE_INSTALL_ARGS if [ $? != 0 ]; then echo "run-build: Error: Boot-strapping post-PJ stage0 with exit code $?." >&2 exit $?