PackIntegrationTest.cs 2.5 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455
  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. namespace Microsoft.NET.Sdk.Razor.Tests
  4. {
  5. public class PackIntegrationTest : AspNetSdkTest
  6. {
  7. public PackIntegrationTest(ITestOutputHelper log) : base(log) { }
  8. [Fact]
  9. public void Pack_NoBuild_Works_IncludesAssembly()
  10. {
  11. var testAsset = "RazorClassLibrary";
  12. var projectDirectory = CreateAspNetSdkTestAsset(testAsset);
  13. var build = new BuildCommand(projectDirectory);
  14. build.Execute().Should().Pass();
  15. var pack = new MSBuildCommand(projectDirectory, "Pack");
  16. var result = pack.Execute("/p:NoBuild=true");
  17. result.Should().Pass();
  18. var outputPath = build.GetOutputDirectory(DefaultTfm, "Debug").ToString();
  19. new FileInfo(Path.Combine(outputPath, "ClassLibrary.dll")).Should().Exist();
  20. new FileInfo(Path.Combine(outputPath, "ClassLibrary.Views.dll")).Should().NotExist();
  21. result.Should().NuSpecContain(
  22. Path.Combine(projectDirectory.Path, "obj", "Debug", "ClassLibrary.1.0.0.nuspec"),
  23. $"<file src=\"{Path.Combine(outputPath, "ClassLibrary.dll")}\" " +
  24. $"target=\"{Path.Combine("lib", DefaultTfm, "ClassLibrary.dll")}\" />");
  25. result.Should().NuSpecDoesNotContain(
  26. Path.Combine(projectDirectory.Path, "obj", "Debug", "ClassLibrary.1.0.0.nuspec"),
  27. $"<file src=\"{Path.Combine(outputPath, "ClassLibrary.Views.dll")}\" " +
  28. $"target=\"{Path.Combine("lib", DefaultTfm, "ClassLibrary.Views.dll")}\" />");
  29. result.Should().NuSpecDoesNotContain(
  30. Path.Combine(projectDirectory.Path, "obj", "Debug", "ClassLibrary.1.0.0.nuspec"),
  31. $"<file src=\"{Path.Combine(outputPath, "ClassLibrary.Views.pdb")}\" " +
  32. $"target=\"{Path.Combine("lib", DefaultTfm, "ClassLibrary.Views.pdb")}\" />");
  33. result.Should().NuSpecDoesNotContain(
  34. Path.Combine(projectDirectory.Path, "obj", "Debug", "ClassLibrary.1.0.0.nuspec"),
  35. $@"<files include=""any/{DefaultTfm}/Views/Shared/_Layout.cshtml"" buildAction=""Content"" />");
  36. result.Should().NuPkgContain(
  37. Path.Combine(build.GetPackageDirectory().FullName, "ClassLibrary.1.0.0.nupkg"),
  38. Path.Combine("lib", DefaultTfm, "ClassLibrary.dll"));
  39. }
  40. }
  41. }