GivenThatWeWantToExcludeTheMainProjectFromTheDepsFile.cs 1.7 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253
  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 GivenThatWeWantToExcludeTheMainProjectFromTheDepsFile : SdkTest
  6. {
  7. public GivenThatWeWantToExcludeTheMainProjectFromTheDepsFile(ITestOutputHelper log) : base(log)
  8. {
  9. }
  10. [Fact]
  11. public void It_builds_successfully()
  12. {
  13. TestProject testProject = new()
  14. {
  15. Name = "ExcludeMainProjectFromDeps",
  16. TargetFrameworks = ToolsetInfo.CurrentTargetFramework,
  17. IsExe = true,
  18. };
  19. TestProject referencedProject = new()
  20. {
  21. Name = "ReferencedProject",
  22. TargetFrameworks = "netstandard2.0",
  23. IsExe = false
  24. };
  25. testProject.ReferencedProjects.Add(referencedProject);
  26. var testProjectInstance = _testAssetsManager.CreateTestProject(testProject, testProject.Name)
  27. .WithProjectChanges((path, project) =>
  28. {
  29. if (Path.GetFileNameWithoutExtension(path) == testProject.Name)
  30. {
  31. var ns = project.Root.Name.Namespace;
  32. var propertyGroup = new XElement(ns + "PropertyGroup");
  33. project.Root.Add(propertyGroup);
  34. propertyGroup.Add(new XElement(ns + "IncludeMainProjectInDepsFile", "false"));
  35. }
  36. });
  37. var buildCommand = new BuildCommand(testProjectInstance);
  38. buildCommand.Execute()
  39. .Should()
  40. .Pass();
  41. }
  42. }
  43. }