GivenThatWeWantToPublishWithGeneratePackageOnBuildAndPackAsTool.cs 1.5 KB

12345678910111213141516171819202122232425262728293031323334353637383940
  1. // Licensed to the .NET Foundation under one or more agreements.
  2. // The .NET Foundation licenses this file to you under the MIT license.
  3. using Microsoft.DotNet.Cli.Utils;
  4. namespace Microsoft.NET.ToolPack.Tests
  5. {
  6. public class GivenThatWeWantToBuildWithGeneratePackageOnBuildAndPackAsTool : SdkTest
  7. {
  8. public GivenThatWeWantToBuildWithGeneratePackageOnBuildAndPackAsTool(ITestOutputHelper log) : base(log)
  9. { }
  10. [Theory]
  11. [InlineData(false, false)]
  12. [InlineData(false, true)]
  13. [InlineData(true, false)]
  14. [InlineData(true, true)]
  15. public void It_builds_successfully(bool generatePackageOnBuild, bool packAsTool)
  16. {
  17. TestAsset testAsset = _testAssetsManager
  18. .CopyTestAsset("HelloWorld", identifier: generatePackageOnBuild.ToString() + packAsTool.ToString())
  19. .WithSource()
  20. .WithProjectChanges((projectPath, project) =>
  21. {
  22. XNamespace ns = project.Root.Name.Namespace;
  23. XElement propertyGroup = project.Root.Elements(ns + "PropertyGroup").First();
  24. propertyGroup.Add(new XElement(ns + "GeneratePackageOnBuild", generatePackageOnBuild.ToString()));
  25. propertyGroup.Add(new XElement(ns + "PackAsTool", packAsTool.ToString()));
  26. });
  27. var buildCommand = new BuildCommand(testAsset);
  28. CommandResult result = buildCommand.Execute();
  29. result.Should()
  30. .Pass();
  31. }
  32. }
  33. }