-
Notifications
You must be signed in to change notification settings - Fork 1k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Fix Publish with GeneratePackageOnBuild=true
What I did is essentially write a different dependency graph in GeneratePackageOnBuild = true to avoid circular dependency . Original bug. I added the https://github.com/dotnet/sdk/pull/3255/files and essentially regressed NuGet/Home#7801. Instead of the logic is in nuget, it is in SDK now. Publish should not skip Build if GeneratePackageOnBuild is true. Or it will mean no build even use Publish verb. But revert 3255 means, #2114 will be back. The solution is to break Pack’s dependency on Build in GeneratePackageOnBuild. But it still need Publish. So I need to let Pack depend directly on no build version of publish. > Why cannot directly use “_PublishNoBuildAlternative”? We want to exclude Build step regardless NoBuild flag is true or not.
- Loading branch information
William Li
committed
Aug 5, 2019
1 parent
527e0e0
commit 15de252
Showing
5 changed files
with
172 additions
and
4 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
53 changes: 53 additions & 0 deletions
53
...rosoft.NET.Build.Tests/GivenThatWeWantToPublishWithGeneratePackageOnBuildAndPackAsTool.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,53 @@ | ||
// Copyright (c) .NET Foundation and contributors. All rights reserved. | ||
// Licensed under the MIT license. See LICENSE file in the project root for full license information. | ||
|
||
using System; | ||
using System.Collections.Generic; | ||
using System.IO; | ||
using System.Linq; | ||
using System.Runtime.CompilerServices; | ||
using System.Xml.Linq; | ||
using FluentAssertions; | ||
using Microsoft.DotNet.Cli.Utils; | ||
using Microsoft.NET.TestFramework; | ||
using Microsoft.NET.TestFramework.Commands; | ||
using NuGet.Packaging; | ||
using Xunit; | ||
using Xunit.Abstractions; | ||
using Microsoft.NET.TestFramework.Assertions; | ||
|
||
namespace Microsoft.NET.ToolPack.Tests | ||
{ | ||
public class GivenThatWeWantToBuildWithGeneratePackageOnBuildAndPackAsTool : SdkTest | ||
{ | ||
public GivenThatWeWantToBuildWithGeneratePackageOnBuildAndPackAsTool(ITestOutputHelper log) : base(log) | ||
{} | ||
|
||
[Theory] | ||
[InlineData(false, false)] | ||
[InlineData(false, true)] | ||
[InlineData(true, false)] | ||
[InlineData(true, true)] | ||
public void It_builds_successfully(bool generatePackageOnBuild, bool packAsTool) | ||
{ | ||
TestAsset testAsset = _testAssetsManager | ||
.CopyTestAsset("HelloWorld", identifier: generatePackageOnBuild.ToString() + packAsTool.ToString()) | ||
.WithSource() | ||
.WithProjectChanges((projectPath, project) => | ||
{ | ||
XNamespace ns = project.Root.Name.Namespace; | ||
XElement propertyGroup = project.Root.Elements(ns + "PropertyGroup").First(); | ||
propertyGroup.Add(new XElement(ns + "GeneratePackageOnBuild", generatePackageOnBuild.ToString())); | ||
propertyGroup.Add(new XElement(ns + "PackAsTool", packAsTool.ToString())); | ||
}); | ||
|
||
var appProjectDirectory = Path.Combine(testAsset.TestRoot); | ||
var buildCommand = new BuildCommand(Log, appProjectDirectory); | ||
|
||
CommandResult result = buildCommand.Execute("/restore"); | ||
|
||
result.Should() | ||
.Pass(); | ||
} | ||
} | ||
} |
82 changes: 82 additions & 0 deletions
82
...soft.NET.Publish.Tests/GivenThatWeWantToPublishWithGeneratePackageOnBuildAndPackAsTool.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,82 @@ | ||
// Copyright (c) .NET Foundation and contributors. All rights reserved. | ||
// Licensed under the MIT license. See LICENSE file in the project root for full license information. | ||
|
||
using System; | ||
using System.Collections.Generic; | ||
using System.IO; | ||
using System.Linq; | ||
using System.Runtime.CompilerServices; | ||
using System.Xml.Linq; | ||
using FluentAssertions; | ||
using Microsoft.DotNet.Cli.Utils; | ||
using Microsoft.NET.TestFramework; | ||
using Microsoft.NET.TestFramework.Commands; | ||
using NuGet.Packaging; | ||
using Xunit; | ||
using Xunit.Abstractions; | ||
using Microsoft.NET.TestFramework.Assertions; | ||
|
||
namespace Microsoft.NET.ToolPack.Tests | ||
{ | ||
public class GivenThatWeWantToPublishWithGeneratePackageOnBuildAndPackAsTool : SdkTest | ||
{ | ||
public GivenThatWeWantToPublishWithGeneratePackageOnBuildAndPackAsTool(ITestOutputHelper log) : base(log) | ||
{} | ||
|
||
[Theory] | ||
[InlineData(false, false)] | ||
[InlineData(false, true)] | ||
[InlineData(true, false)] | ||
[InlineData(true, true)] | ||
public void It_publishes_successfully(bool generatePackageOnBuild, bool packAsTool) | ||
{ | ||
Console.WriteLine(generatePackageOnBuild.ToString() + packAsTool.ToString()); | ||
|
||
TestAsset testAsset = _testAssetsManager | ||
.CopyTestAsset("HelloWorld", identifier: generatePackageOnBuild.ToString() + packAsTool.ToString()) | ||
.WithSource() | ||
.WithProjectChanges((projectPath, project) => | ||
{ | ||
XNamespace ns = project.Root.Name.Namespace; | ||
XElement propertyGroup = project.Root.Elements(ns + "PropertyGroup").First(); | ||
propertyGroup.Add(new XElement(ns + "GeneratePackageOnBuild", generatePackageOnBuild.ToString())); | ||
propertyGroup.Add(new XElement(ns + "PackAsTool", packAsTool.ToString())); | ||
}); | ||
|
||
var appProjectDirectory = Path.Combine(testAsset.TestRoot); | ||
var publishCommand = new PublishCommand(Log, appProjectDirectory); | ||
|
||
CommandResult result = publishCommand.Execute("/restore"); | ||
|
||
result.Should() | ||
.Pass(); | ||
} | ||
|
||
[Theory] | ||
[InlineData(false, false)] | ||
[InlineData(false, true)] | ||
[InlineData(true, false)] | ||
[InlineData(true, true)] | ||
public void It_builds_successfully(bool generatePackageOnBuild, bool packAsTool) | ||
{ | ||
TestAsset testAsset = _testAssetsManager | ||
.CopyTestAsset("HelloWorld", identifier: generatePackageOnBuild.ToString() + packAsTool.ToString()) | ||
.WithSource() | ||
.WithProjectChanges((projectPath, project) => | ||
{ | ||
XNamespace ns = project.Root.Name.Namespace; | ||
XElement propertyGroup = project.Root.Elements(ns + "PropertyGroup").First(); | ||
propertyGroup.Add(new XElement(ns + "GeneratePackageOnBuild", generatePackageOnBuild.ToString())); | ||
propertyGroup.Add(new XElement(ns + "PackAsTool", packAsTool.ToString())); | ||
}); | ||
|
||
var appProjectDirectory = Path.Combine(testAsset.TestRoot); | ||
var buildCommand = new BuildCommand(Log, appProjectDirectory); | ||
|
||
CommandResult result = buildCommand.Execute("/restore"); | ||
|
||
result.Should() | ||
.Pass(); | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters