From 4fbd449d25072821444d2b8c8c25331d6a8423a1 Mon Sep 17 00:00:00 2001 From: Brandon Dahler Date: Fri, 14 Dec 2018 12:42:10 -0500 Subject: [PATCH] Allow metadata-only AppendToVersion --- .../OctoPack.Tasks/CreateOctoPackPackage.cs | 6 ++- .../Integration/SampleSolutionBuildFixture.cs | 48 +++++++++++++++++++ 2 files changed, 53 insertions(+), 1 deletion(-) diff --git a/source/OctoPack.Tasks/CreateOctoPackPackage.cs b/source/OctoPack.Tasks/CreateOctoPackPackage.cs index 2b8a98d..968d42d 100644 --- a/source/OctoPack.Tasks/CreateOctoPackPackage.cs +++ b/source/OctoPack.Tasks/CreateOctoPackPackage.cs @@ -401,7 +401,11 @@ private void UpdateVersionWithAppendValue(XContainer nuSpec) var version = GetVersionElementFromNuSpec(nuSpec); - version.Value = $"{PackageVersion ?? version.Value}-{AppendToVersion.Trim()}"; + if (AppendToVersion[0] != '+') + version.Value = $"{PackageVersion ?? version.Value}-{AppendToVersion.Trim()}"; + else + version.Value = $"{PackageVersion ?? version.Value}{AppendToVersion.Trim()}"; + PackageVersion = version.Value; } diff --git a/source/OctoPack.Tests/Integration/SampleSolutionBuildFixture.cs b/source/OctoPack.Tests/Integration/SampleSolutionBuildFixture.cs index 7cc4741..8a64920 100644 --- a/source/OctoPack.Tests/Integration/SampleSolutionBuildFixture.cs +++ b/source/OctoPack.Tests/Integration/SampleSolutionBuildFixture.cs @@ -494,6 +494,54 @@ public void ShouldAllowAppendingValueToVersionWithExplicitPackageVersion() "Web.Debug.config")); } + [Test] + public void ShouldAllowAppendingValueToVersionWithMetadataOnly() + { + MsBuild("Samples.sln /p:RunOctoPack=true /p:OctoPackAppendToVersion=+Foo /p:Configuration=Release /v:m"); + + AssertPackage(@"Sample.ConsoleApp\obj\octopacked\Sample.ConsoleApp.2.1.0.1+Foo.nupkg", + pkg => pkg.AssertContents( + "Sample.ConsoleApp.exe", + "Sample.ConsoleApp.exe.config", + "Sample.ConsoleApp.pdb")); + + AssertPackage(@"Sample.WebApp\obj\octopacked\Sample.WebApp.3.1.0-dev+Foo.nupkg", + pkg => pkg.AssertContents( + "bin\\*.dll", + "bin\\*.xml", + "bin\\Sample.WebApp.dll", + "bin\\Sample.WebApp.pdb", + "Content\\*.css", + "Content\\*.png", + "Content\\LinkedFile.txt", + "Scripts\\*.js", + "Views\\Web.config", + "Views\\*.cshtml", + "Global.asax", + "Web.config", + "Web.Release.config", + "Web.Debug.config")); + + AssertPackage(@"Sample.WebAppWithSpec\obj\octopacked\Sample.WebAppWithSpec.1.0.13-demo+Foo.nupkg", + pkg => pkg.AssertContents( + "bin\\*.dll", + "bin\\*.xml", + "bin\\Sample.WebAppWithSpec.dll", + "bin\\Sample.WebAppWithSpec.pdb", + "Content\\*.css", + "Content\\*.png", + "Content\\LinkedFile.txt", + "Scripts\\*.js", + "Views\\Web.config", + "Views\\*.cshtml", + "Views\\Deploy.ps1", + "Deploy.ps1", + "Global.asax", + "Web.config", + "Web.Release.config", + "Web.Debug.config")); + } + [Test] public void ShouldSupportRelativeOutputDirectories() {