Skip to content

Commit b18974b

Browse files
committed
Fix test
1 parent 7f0a420 commit b18974b

File tree

2 files changed

+6
-1
lines changed

2 files changed

+6
-1
lines changed

src/Microsoft.Build.Utilities.ProjectCreation.UnitTests/SolutionTests.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ public void BasicTest()
2828

2929
File.ReadAllText(solutionFileFullPath).ShouldBe(
3030
@$"Microsoft Visual Studio Solution File, Format Version 12.00
31-
Project(""{{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}}"") = ""{project1Name}"", ""{project1FullPath}"", ""{{{projectInSolution.Id.ToString().ToUpperInvariant()}}}""
31+
Project(""{{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}}"") = ""{project1Name}"", ""{project1FullPath.Replace(Path.PathSeparator, '\\')}"", ""{{{projectInSolution.Id.ToString().ToUpperInvariant()}}}""
3232
EndProject
3333
Global
3434
GlobalSection(SolutionProperties) = preSolution

src/Microsoft.Build.Utilities.ProjectCreation/SolutionCreator.cs

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -211,6 +211,11 @@ public SolutionCreator TryProject(ProjectCreator project, out SolutionProjectMod
211211
/// <returns>The current <see cref="SolutionCreator" />.</returns>
212212
public SolutionCreator TryProject(ProjectCreator project, SolutionFolderModel? folder, out SolutionProjectModel projectInSolution, string? projectTypeName = null)
213213
{
214+
if (string.IsNullOrWhiteSpace(project.FullPath))
215+
{
216+
throw new InvalidOperationException("The project must have a valid path before it can be added to the solution.");
217+
}
218+
214219
project.Save();
215220

216221
projectInSolution = _lastProject = _solutionModel.AddProject(project.FullPath, projectTypeName, folder);

0 commit comments

Comments
 (0)