GivenThatWeWantToBuildACppCliProjectWithTransitiveDeps.cs 2.7 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364
  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.Build.Tests
  4. {
  5. public class GivenThatWeWantToBuildACppCliProjectWithTransitiveDeps : SdkTest
  6. {
  7. public GivenThatWeWantToBuildACppCliProjectWithTransitiveDeps(ITestOutputHelper log) : base(log)
  8. {
  9. _buildAsset = new Lazy<TestAsset>(BuildAsset);
  10. }
  11. private readonly Lazy<TestAsset> _buildAsset;
  12. [FullMSBuildOnlyFact(Skip = "https://github.com/dotnet/sdk/issues/3785")]
  13. public void It_can_generate_correct_depsJson_file()
  14. {
  15. TestAsset testAsset = _buildAsset.Value;
  16. string depsJsonContent = File.ReadAllText(Path.Combine(testAsset.TestRoot, "NETCoreCppCliTest", "Debug",
  17. "NETCoreCppCliTest.deps.json"));
  18. depsJsonContent.Should().Contain("NETCoreCppCliTestB.dll", "should contain direct project reference");
  19. depsJsonContent.Should().Contain("NETCoreCppCliTestC.dll", "should contain transitive reference");
  20. }
  21. [FullMSBuildOnlyFact(Skip = "https://github.com/dotnet/sdk/issues/3785")]
  22. public void It_can_generate_all_runtimeconfig_files_to_output_folder()
  23. {
  24. TestAsset testAsset = _buildAsset.Value;
  25. var outputDirectory = new DirectoryInfo(Path.Combine(testAsset.TestRoot, "NETCoreCppCliTest", "Debug"));
  26. outputDirectory.Should().HaveFiles(new[]
  27. {
  28. "NETCoreCppCliTest.runtimeconfig.json", "NETCoreCppCliTestB.runtimeconfig.json",
  29. "NETCoreCppCliTestC.runtimeconfig.json"
  30. });
  31. }
  32. [FullMSBuildOnlyFact(Skip = "https://github.com/dotnet/sdk/issues/3785")]
  33. public void It_can_generate_all_depsjson_files_to_output_folder()
  34. {
  35. TestAsset testAsset = _buildAsset.Value;
  36. var outputDirectory = new DirectoryInfo(Path.Combine(testAsset.TestRoot, "NETCoreCppCliTest", "Debug"));
  37. outputDirectory.Should().HaveFiles(new[]
  38. {
  39. "NETCoreCppCliTest.deps.json", "NETCoreCppCliTestB.deps.json", "NETCoreCppCliTestC.deps.json"
  40. });
  41. }
  42. private TestAsset BuildAsset()
  43. {
  44. var testAsset = _testAssetsManager
  45. .CopyTestAsset("NetCoreCppCliLibWithTransitiveDeps")
  46. .WithSource();
  47. // build projects separately with BuildProjectReferences=false to simulate VS build behavior
  48. new BuildCommand(testAsset, "NETCoreCppCliTest")
  49. .Execute("-p:Platform=win32")
  50. .Should()
  51. .Pass();
  52. return testAsset;
  53. }
  54. }
  55. }