Fix dotnet sln add for multitargeted C# and VB projects.
This commit integrates a fix from the SDK repo that sets `DefaultProjectTypeGuid` for VB and C# projects when the projects are multitargeting. This property is used by `dotnet sln add` to determine the project type guid to map in the solution file. Adding additional tests that cover the multitargeting scenario for `dotnet sln add`. Fixes #9477.
This commit is contained in:
parent
ed8ee9f23b
commit
96c9dc375a
9 changed files with 141 additions and 1 deletions
|
@ -1012,6 +1012,72 @@ EndGlobal
|
|||
.Should().BeVisuallyEquivalentTo(ExpectedSlnFileAfterAddingProjectWithAdditionalConfigs);
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void ItAddsACSharpProjectThatIsMultitargeted()
|
||||
{
|
||||
var solutionDirectory = TestAssets
|
||||
.Get("TestAppsWithSlnAndMultitargetedProjects")
|
||||
.CreateInstance()
|
||||
.WithSourceFiles()
|
||||
.Root
|
||||
.FullName;
|
||||
|
||||
var slnFullPath = Path.Combine(solutionDirectory, "App.sln");
|
||||
var projectToAdd = Path.Combine("MultitargetedCS", "MultitargetedCS.csproj");
|
||||
|
||||
new DotnetCommand()
|
||||
.WithWorkingDirectory(solutionDirectory)
|
||||
.ExecuteWithCapturedOutput($"sln add {projectToAdd}")
|
||||
.Should()
|
||||
.Pass()
|
||||
.And
|
||||
.HaveStdOutContaining(string.Format(CommonLocalizableStrings.ProjectAddedToTheSolution, projectToAdd));
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void ItAddsAVisualBasicProjectThatIsMultitargeted()
|
||||
{
|
||||
var solutionDirectory = TestAssets
|
||||
.Get("TestAppsWithSlnAndMultitargetedProjects")
|
||||
.CreateInstance()
|
||||
.WithSourceFiles()
|
||||
.Root
|
||||
.FullName;
|
||||
|
||||
var slnFullPath = Path.Combine(solutionDirectory, "App.sln");
|
||||
var projectToAdd = Path.Combine("MultitargetedVB", "MultitargetedVB.vbproj");
|
||||
|
||||
new DotnetCommand()
|
||||
.WithWorkingDirectory(solutionDirectory)
|
||||
.ExecuteWithCapturedOutput($"sln add {projectToAdd}")
|
||||
.Should()
|
||||
.Pass()
|
||||
.And
|
||||
.HaveStdOutContaining(string.Format(CommonLocalizableStrings.ProjectAddedToTheSolution, projectToAdd));
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void ItAddsAnFSharpProjectThatIsMultitargeted()
|
||||
{
|
||||
var solutionDirectory = TestAssets
|
||||
.Get("TestAppsWithSlnAndMultitargetedProjects")
|
||||
.CreateInstance()
|
||||
.WithSourceFiles()
|
||||
.Root
|
||||
.FullName;
|
||||
|
||||
var slnFullPath = Path.Combine(solutionDirectory, "App.sln");
|
||||
var projectToAdd = Path.Combine("MultitargetedFS", "MultitargetedFS.fsproj");
|
||||
|
||||
new DotnetCommand()
|
||||
.WithWorkingDirectory(solutionDirectory)
|
||||
.ExecuteWithCapturedOutput($"sln add {projectToAdd}")
|
||||
.Should()
|
||||
.Pass()
|
||||
.And
|
||||
.HaveStdOutContaining(string.Format(CommonLocalizableStrings.ProjectAddedToTheSolution, projectToAdd));
|
||||
}
|
||||
|
||||
private string GetExpectedSlnContents(
|
||||
string slnPath,
|
||||
string slnTemplate,
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue