-
Notifications
You must be signed in to change notification settings - Fork 1.4k
Don't build a solution when -preprocess or -targets is passed on the command line #8588
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from all commits
dd5c539
139686c
e99dc99
ba4e183
d9f8d71
60c876e
ab5c0e5
ac153bb
ac95c3c
0ff6099
86b2d3b
c66c83d
af465fb
d6b923c
c70ca76
337bc16
da8d39c
f677419
6c55364
2b15ac7
b1a00a0
d9586cb
2363b4a
c068c0a
662b8cb
8ac944a
aaab028
0340297
914f630
9e56bd4
39ee0b2
b3dcb3a
aaeee91
807ceee
2491b83
40313cd
0b7a650
8b29326
207894c
2eae849
7c2cd3f
d4a0d9a
2ced38f
8ca8f9d
fc59fb9
235e91c
dfb5452
207bd97
23aa710
583b659
850c8b9
0039b86
39f85c0
9891615
8cbf2d8
55b84c7
f734048
881bd40
48cb4e0
ac1082b
f213799
c954b43
5a095aa
0df505e
c758cbd
d8984a1
1024587
41a33c8
0f9f448
be0a1ac
166e325
bb70d45
61d1ae9
e749450
9f3f56e
951cb9f
df11069
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -758,10 +758,13 @@ public static ExitType Execute( | |
| // Only display the message if /m isn't provided | ||
| if (cpuCount == 1 && FileUtilities.IsSolutionFilename(projectFile) && verbosity > LoggerVerbosity.Minimal | ||
| && switchesNotFromAutoResponseFile[CommandLineSwitches.ParameterizedSwitch.MaxCPUCount].Length == 0 | ||
| && switchesFromAutoResponseFile[CommandLineSwitches.ParameterizedSwitch.MaxCPUCount].Length == 0) | ||
| && switchesFromAutoResponseFile[CommandLineSwitches.ParameterizedSwitch.MaxCPUCount].Length == 0 | ||
| && preprocessWriter != null | ||
| && targetsWriter != null) | ||
| { | ||
| Console.WriteLine(ResourceUtilities.GetResourceString("PossiblyOmittedMaxCPUSwitch")); | ||
| } | ||
|
|
||
| if (preprocessWriter != null && !BuildEnvironmentHelper.Instance.RunningTests) | ||
| { | ||
| // Indicate to the engine that it can NOT toss extraneous file content: we want to | ||
|
|
@@ -1207,8 +1210,8 @@ internal static bool BuildProject( | |
|
|
||
| ToolsetDefinitionLocations toolsetDefinitionLocations = ToolsetDefinitionLocations.Default; | ||
|
|
||
| bool preprocessOnly = preprocessWriter != null && !FileUtilities.IsSolutionFilename(projectFile); | ||
| bool targetsOnly = targetsWriter != null && !FileUtilities.IsSolutionFilename(projectFile); | ||
| bool isPreprocess = preprocessWriter != null; | ||
| bool isTargets = targetsWriter != null; | ||
|
|
||
| projectCollection = new ProjectCollection( | ||
| globalProperties, | ||
|
|
@@ -1217,7 +1220,7 @@ internal static bool BuildProject( | |
| toolsetDefinitionLocations, | ||
| cpuCount, | ||
| onlyLogCriticalEvents, | ||
| loadProjectsReadOnly: !preprocessOnly, | ||
| loadProjectsReadOnly: !isPreprocess, | ||
| useAsynchronousLogging: true, | ||
| reuseProjectRootElementCache: s_isServerNode); | ||
|
|
||
|
|
@@ -1226,9 +1229,11 @@ internal static bool BuildProject( | |
| ThrowInvalidToolsVersionInitializationException(projectCollection.Toolsets, toolsVersion); | ||
| } | ||
|
|
||
| bool isSolution = FileUtilities.IsSolutionFilename(projectFile); | ||
|
|
||
| #if FEATURE_XML_SCHEMA_VALIDATION | ||
| // If the user has requested that the schema be validated, do that here. | ||
| if (needToValidateProject && !FileUtilities.IsSolutionFilename(projectFile)) | ||
| if (needToValidateProject && !isSolution) | ||
| { | ||
| Microsoft.Build.Evaluation.Project project = projectCollection.LoadProject(projectFile, globalProperties, toolsVersion); | ||
| Microsoft.Build.Evaluation.Toolset toolset = projectCollection.GetToolset(toolsVersion ?? project.ToolsVersion); | ||
|
|
@@ -1246,22 +1251,41 @@ internal static bool BuildProject( | |
| } | ||
| #endif | ||
|
|
||
| if (preprocessOnly) | ||
| if (isPreprocess) | ||
| { | ||
| Project project = projectCollection.LoadProject(projectFile, globalProperties, toolsVersion); | ||
| // TODO: Support /preprocess for solution files. https://github.com/dotnet/msbuild/issues/7697 | ||
| if (isSolution) | ||
| { | ||
| Console.WriteLine(ResourceUtilities.GetResourceString("UnsupportedSwitchForSolutionFiles"), CommandLineSwitches.ParameterizedSwitch.Preprocess); | ||
jrdodds marked this conversation as resolved.
Show resolved
Hide resolved
|
||
| success = false; | ||
| } | ||
| else | ||
| { | ||
| Project project = projectCollection.LoadProject(projectFile, globalProperties, toolsVersion); | ||
|
|
||
| project.SaveLogicalProject(preprocessWriter); | ||
| project.SaveLogicalProject(preprocessWriter); | ||
|
|
||
| projectCollection.UnloadProject(project); | ||
| success = true; | ||
| projectCollection.UnloadProject(project); | ||
|
|
||
| success = true; | ||
| } | ||
| } | ||
|
|
||
| if (targetsOnly) | ||
| if (isTargets) | ||
| { | ||
| success = PrintTargets(projectFile, toolsVersion, globalProperties, targetsWriter, projectCollection); | ||
| // TODO: Support /targets for solution files. https://github.com/dotnet/msbuild/issues/7697 | ||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I don't know what the repo standard is (it's not my repo) but IMO todo comments and links to issues usually just make the code cluttered (often for years) when the same info could be found from the original PR or commit message. Eg in this case I'd a simply comment something like "// /targets could be supported for solution files in future"
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I added the TODO comments. I'm actively working on the issue to support /targets and /preprocess for solution files and this is intended to be an interim change. An earlier review requested adding the links. Regardless I have no issue with changing the comments if that's the standard and/or the consensus. Thanks
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I personally prefer to have the comment in the file, as it is now, as long as the link is to a permalink (we still have some that are like "regression test for #1283456" and I have no idea even what database that was in . . .) |
||
| if (isSolution) | ||
| { | ||
| Console.WriteLine(ResourceUtilities.GetResourceString("UnsupportedSwitchForSolutionFiles"), CommandLineSwitches.ParameterizedSwitch.Targets); | ||
| success = false; | ||
| } | ||
| else | ||
| { | ||
| success = PrintTargets(projectFile, toolsVersion, globalProperties, targetsWriter, projectCollection); | ||
| } | ||
| } | ||
|
|
||
| if (!preprocessOnly && !targetsOnly) | ||
| if (!isPreprocess && !isTargets) | ||
| { | ||
| BuildParameters parameters = new BuildParameters(projectCollection); | ||
|
|
||
|
|
||
Uh oh!
There was an error while loading. Please reload this page.