diff --git a/eng/Versions.props b/eng/Versions.props index 8e634804ad6..2f588dda9d6 100644 --- a/eng/Versions.props +++ b/eng/Versions.props @@ -2,7 +2,7 @@ - 16.10.0release + 16.10.1release 15.1.0.0 preview true diff --git a/src/Build.UnitTests/Construction/SolutionProjectGenerator_Tests.cs b/src/Build.UnitTests/Construction/SolutionProjectGenerator_Tests.cs index 5d536380d86..b75fa9b28be 100644 --- a/src/Build.UnitTests/Construction/SolutionProjectGenerator_Tests.cs +++ b/src/Build.UnitTests/Construction/SolutionProjectGenerator_Tests.cs @@ -175,6 +175,46 @@ public void SolutionFilterFiltersProjects() } } + [Fact] + public void BuildProjectAsTarget() + { + using (TestEnvironment testEnvironment = TestEnvironment.Create()) + { + TransientTestFolder folder = testEnvironment.CreateFolder(createFolder: true); + TransientTestFolder classLibFolder = testEnvironment.CreateFolder(Path.Combine(folder.Path, "classlib"), createFolder: true); + TransientTestFile classLibrary = testEnvironment.CreateFile(classLibFolder, "classlib.csproj", + @" + + + + + "); + + TransientTestFolder simpleProjectFolder = testEnvironment.CreateFolder(Path.Combine(folder.Path, "simpleProject"), createFolder: true); + TransientTestFile simpleProject = testEnvironment.CreateFile(simpleProjectFolder, "simpleProject.csproj", + @" + + + + + "); + + TransientTestFile solutionFile = testEnvironment.CreateFile(folder, "testFolder.sln", + @" +Microsoft Visual Studio Solution File, Format Version 12.00 +# Visual Studio Version 16 +VisualStudioVersion = 16.6.30114.105 +MinimumVisualStudioVersion = 10.0.40219.1 +Project(""{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}"") = ""simpleProject"", ""simpleProject\simpleProject.csproj"", ""{AA52A05F-A9C0-4C89-9933-BF976A304C91}"" +EndProject +Project(""{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}"") = ""classlib"", ""classlib\classlib.csproj"", ""{80B8E6B8-E46D-4456-91B1-848FD35C4AB9}"" +EndProject + "); + RunnerUtilities.ExecMSBuild(solutionFile.Path + " /t:classlib", out bool success); + success.ShouldBeTrue(); + } + } + /// /// Verify the AddNewErrorWarningMessageElement method /// diff --git a/src/Build/Construction/Solution/SolutionProjectGenerator.cs b/src/Build/Construction/Solution/SolutionProjectGenerator.cs index 3888a265e50..4b1edd904a4 100644 --- a/src/Build/Construction/Solution/SolutionProjectGenerator.cs +++ b/src/Build/Construction/Solution/SolutionProjectGenerator.cs @@ -781,8 +781,9 @@ private void EvaluateAndAddProjects(List projectsInOrder, Lis AddTraversalTargetForProject(traversalInstance, project, projectConfiguration, "Rebuild", "BuildOutput", canBuildDirectly); AddTraversalTargetForProject(traversalInstance, project, projectConfiguration, "Publish", null, canBuildDirectly); - // Add any other targets specified by the user that were not already added - foreach (string targetName in _targetNames.Except(traversalInstance.Targets.Keys, StringComparer.OrdinalIgnoreCase)) + // Add any other targets specified by the user that were not already added. A target's presence or absence must be determined at the last + // minute because whether traversalInstance.Targets.ContainsKey(i) is true or not can change during the enumeration. + foreach (string targetName in _targetNames.Where(i => !traversalInstance.Targets.ContainsKey(i))) { AddTraversalTargetForProject(traversalInstance, project, projectConfiguration, targetName, null, canBuildDirectly); } @@ -796,7 +797,7 @@ private void EvaluateAndAddProjects(List projectsInOrder, Lis } // Add any other targets specified by the user that were not already added - foreach (string targetName in _targetNames.Except(traversalInstance.Targets.Keys, StringComparer.OrdinalIgnoreCase)) + foreach (string targetName in _targetNames.Where(i => !traversalInstance.Targets.ContainsKey(i))) { AddTraversalReferencesTarget(traversalInstance, targetName, null); } @@ -1201,7 +1202,7 @@ private ProjectInstance CreateMetaproject(ProjectInstance traversalProject, Proj AddMetaprojectTargetForWebProject(traversalProject, metaprojectInstance, project, "Rebuild"); AddMetaprojectTargetForWebProject(traversalProject, metaprojectInstance, project, "Publish"); - foreach (string targetName in _targetNames.Except(metaprojectInstance.Targets.Keys, StringComparer.OrdinalIgnoreCase)) + foreach (string targetName in _targetNames.Where(i => !metaprojectInstance.Targets.ContainsKey(i))) { AddMetaprojectTargetForWebProject(traversalProject, metaprojectInstance, project, targetName); } @@ -1221,7 +1222,7 @@ private ProjectInstance CreateMetaproject(ProjectInstance traversalProject, Proj AddMetaprojectTargetForManagedProject(traversalProject, metaprojectInstance, project, projectConfiguration, "Rebuild", targetOutputItemName); AddMetaprojectTargetForManagedProject(traversalProject, metaprojectInstance, project, projectConfiguration, "Publish", null); - foreach (string targetName in _targetNames.Except(metaprojectInstance.Targets.Keys, StringComparer.OrdinalIgnoreCase)) + foreach (string targetName in _targetNames.Where(i => !metaprojectInstance.Targets.ContainsKey(i))) { AddMetaprojectTargetForManagedProject(traversalProject, metaprojectInstance, project, projectConfiguration, targetName, null); } @@ -1233,7 +1234,7 @@ private ProjectInstance CreateMetaproject(ProjectInstance traversalProject, Proj AddMetaprojectTargetForUnknownProjectType(traversalProject, metaprojectInstance, project, "Rebuild", unknownProjectTypeErrorMessage); AddMetaprojectTargetForUnknownProjectType(traversalProject, metaprojectInstance, project, "Publish", unknownProjectTypeErrorMessage); - foreach (string targetName in _targetNames.Except(metaprojectInstance.Targets.Keys, StringComparer.OrdinalIgnoreCase)) + foreach (string targetName in _targetNames.Where(i => !metaprojectInstance.Targets.ContainsKey(i))) { AddMetaprojectTargetForUnknownProjectType(traversalProject, metaprojectInstance, project, targetName, unknownProjectTypeErrorMessage); }