Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
77 commits
Select commit Hold shift + click to select a range
dd5c539
don't build a sln when -preprocess or -targets is passed
jrdodds Aug 4, 2022
139686c
Merge branch 'dotnet:main' into Solution-Targets
jrdodds Aug 5, 2022
e99dc99
Merge branch 'dotnet:main' into Solution-Targets
jrdodds Aug 9, 2022
ba4e183
Merge branch 'dotnet:main' into Solution-Targets
jrdodds Aug 11, 2022
d9f8d71
Merge branch 'dotnet:main' into Solution-Targets
jrdodds Aug 12, 2022
60c876e
Merge branch 'dotnet:main' into Solution-Targets
jrdodds Aug 13, 2022
ab5c0e5
Merge branch 'dotnet:main' into Solution-Targets
jrdodds Aug 15, 2022
ac153bb
Merge branch 'dotnet:main' into Solution-Targets
jrdodds Aug 16, 2022
ac95c3c
Merge branch 'dotnet:main' into Solution-Targets
jrdodds Aug 20, 2022
0ff6099
Merge branch 'dotnet:main' into Solution-Targets
jrdodds Aug 26, 2022
86b2d3b
Merge branch 'dotnet:main' into Solution-Targets
jrdodds Aug 30, 2022
c66c83d
Merge branch 'dotnet:main' into Solution-Targets
jrdodds Sep 1, 2022
af465fb
Merge branch 'dotnet:main' into Solution-Targets
jrdodds Sep 3, 2022
d6b923c
Merge branch 'dotnet:main' into Solution-Targets
jrdodds Sep 8, 2022
c70ca76
Merge branch 'dotnet:main' into Solution-Targets
jrdodds Sep 19, 2022
337bc16
Merge branch 'dotnet:main' into Solution-Targets
jrdodds Sep 22, 2022
da8d39c
Merge branch 'dotnet:main' into Solution-Targets
jrdodds Sep 23, 2022
f677419
Merge branch 'dotnet:main' into Solution-Targets
jrdodds Sep 25, 2022
6c55364
Merge branch 'dotnet:main' into Solution-Targets
jrdodds Sep 28, 2022
2b15ac7
Merge branch 'dotnet:main' into Solution-Targets
jrdodds Sep 30, 2022
b1a00a0
Merge branch 'dotnet:main' into Solution-Targets
jrdodds Oct 3, 2022
d9586cb
Merge branch 'dotnet:main' into Solution-Targets
jrdodds Oct 7, 2022
2363b4a
Merge branch 'dotnet:main' into Solution-Targets
jrdodds Oct 9, 2022
c068c0a
Merge branch 'dotnet:main' into Solution-Targets
jrdodds Oct 11, 2022
662b8cb
Merge branch 'dotnet:main' into Solution-Targets
jrdodds Oct 13, 2022
8ac944a
Merge branch 'dotnet:main' into Solution-Targets
jrdodds Oct 17, 2022
aaab028
Merge branch 'dotnet:main' into Solution-Targets
jrdodds Oct 19, 2022
0340297
Merge branch 'dotnet:main' into Solution-Targets
jrdodds Oct 19, 2022
914f630
Merge branch 'dotnet:main' into Solution-Targets
jrdodds Oct 20, 2022
9e56bd4
Merge branch 'dotnet:main' into Solution-Targets
jrdodds Oct 23, 2022
39ee0b2
Merge branch 'dotnet:main' into Solution-Targets
jrdodds Oct 24, 2022
b3dcb3a
Merge branch 'dotnet:main' into Solution-Targets
jrdodds Oct 25, 2022
aaeee91
Merge branch 'dotnet:main' into Solution-Targets
jrdodds Oct 27, 2022
807ceee
Merge branch 'dotnet:main' into Solution-Targets
jrdodds Nov 3, 2022
2491b83
Merge branch 'dotnet:main' into Solution-Targets
jrdodds Nov 4, 2022
40313cd
Merge branch 'dotnet:main' into Solution-Targets
jrdodds Nov 5, 2022
0b7a650
Merge branch 'dotnet:main' into Solution-Targets
jrdodds Nov 9, 2022
8b29326
Merge branch 'dotnet:main' into Solution-Targets
jrdodds Nov 12, 2022
207894c
Merge branch 'dotnet:main' into Solution-Targets
jrdodds Nov 14, 2022
2eae849
Merge branch 'dotnet:main' into Solution-Targets
jrdodds Nov 18, 2022
7c2cd3f
Merge branch 'dotnet:main' into Solution-Targets
jrdodds Nov 22, 2022
d4a0d9a
Merge branch 'dotnet:main' into Solution-Targets
jrdodds Nov 23, 2022
2ced38f
Merge branch 'dotnet:main' into Solution-Targets
jrdodds Dec 1, 2022
8ca8f9d
Merge branch 'dotnet:main' into Solution-Targets
jrdodds Dec 6, 2022
fc59fb9
Merge branch 'dotnet:main' into Solution-Targets
jrdodds Dec 7, 2022
235e91c
Merge branch 'dotnet:main' into Solution-Targets
jrdodds Dec 8, 2022
dfb5452
Merge branch 'dotnet:main' into Solution-Targets
jrdodds Dec 12, 2022
207bd97
Merge branch 'dotnet:main' into Solution-Targets
jrdodds Dec 13, 2022
23aa710
Merge branch 'dotnet:main' into Solution-Targets
jrdodds Dec 14, 2022
583b659
Merge branch 'dotnet:main' into Solution-Targets
jrdodds Dec 16, 2022
850c8b9
Merge branch 'dotnet:main' into Solution-Targets
jrdodds Dec 19, 2022
0039b86
Merge branch 'dotnet:main' into Solution-Targets
jrdodds Dec 21, 2022
39f85c0
Merge branch 'dotnet:main' into Solution-Targets
jrdodds Jan 3, 2023
9891615
Merge branch 'dotnet:main' into Solution-Targets
jrdodds Jan 4, 2023
8cbf2d8
Merge branch 'dotnet:main' into Solution-Targets
jrdodds Jan 5, 2023
55b84c7
Merge branch 'dotnet:main' into Solution-Targets
jrdodds Jan 8, 2023
f734048
Merge branch 'dotnet:main' into Solution-Targets
jrdodds Jan 14, 2023
881bd40
Merge branch 'dotnet:main' into Solution-Targets
jrdodds Jan 23, 2023
48cb4e0
Merge branch 'dotnet:main' into Solution-Targets
jrdodds Jan 30, 2023
ac1082b
Merge branch 'dotnet:main' into Solution-Targets
jrdodds Feb 1, 2023
f213799
Merge branch 'dotnet:main' into Solution-Targets
jrdodds Feb 6, 2023
c954b43
Merge branch 'dotnet:main' into Solution-Targets
jrdodds Feb 7, 2023
5a095aa
Merge branch 'dotnet:main' into Solution-Targets
jrdodds Feb 8, 2023
0df505e
Merge branch 'dotnet:main' into Solution-Targets
jrdodds Mar 6, 2023
c758cbd
Merge branch 'dotnet:main' into Solution-Targets
jrdodds Mar 9, 2023
d8984a1
Merge branch 'dotnet:main' into Solution-Targets
jrdodds Mar 11, 2023
1024587
Merge branch 'dotnet:main' into Solution-Targets
jrdodds Mar 13, 2023
41a33c8
Merge branch 'dotnet:main' into Solution-Targets
jrdodds Mar 14, 2023
0f9f448
Merge branch 'dotnet:main' into Solution-Targets
jrdodds Mar 15, 2023
be0a1ac
Merge branch 'dotnet:main' into Solution-Targets
jrdodds Mar 22, 2023
166e325
Add message for unsupported switches on solution files
jrdodds Mar 23, 2023
bb70d45
modify comment
jrdodds Mar 23, 2023
61d1ae9
changes based on review
jrdodds Mar 24, 2023
e749450
changes based on review
jrdodds Mar 24, 2023
9f3f56e
Merge branch 'dotnet:main' into Solution-Targets-Dont-Build
jrdodds Mar 27, 2023
951cb9f
Merge branch 'dotnet:main' into Solution-Targets-Dont-Build
jrdodds Mar 29, 2023
df11069
Merge branch 'dotnet:main' into Solution-Targets-Dont-Build
jrdodds Apr 1, 2023
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions src/MSBuild/Resources/Strings.resx
Original file line number Diff line number Diff line change
Expand Up @@ -1349,6 +1349,9 @@
<data name="NotWarnAsErrorWithoutWarnAsError" Visibility="Public">
<value>MSBUILD : error MSB1062: The -warnnotaserror switch cannot be specified unless the -warnaserror switch is also specified and left empty.</value>
<comment>{StrBegin="MSBUILD : error MSB1062: "}LOCALIZATION: The prefix "MSBUILD : error MSBxxxx:", "-warnnotaserror" and "-warnaserror" should not be localized.</comment>
</data>
<data name="UnsupportedSwitchForSolutionFiles" Visibility="Public">
<value>The '{0}' switch is not supported for solution files.</value>
</data>
<!--
The command line message bucket is: MSB1001 - MSB1999
Expand Down
5 changes: 5 additions & 0 deletions src/MSBuild/Resources/xlf/Strings.cs.xlf

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

5 changes: 5 additions & 0 deletions src/MSBuild/Resources/xlf/Strings.de.xlf

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

5 changes: 5 additions & 0 deletions src/MSBuild/Resources/xlf/Strings.es.xlf

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

5 changes: 5 additions & 0 deletions src/MSBuild/Resources/xlf/Strings.fr.xlf

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

5 changes: 5 additions & 0 deletions src/MSBuild/Resources/xlf/Strings.it.xlf

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

5 changes: 5 additions & 0 deletions src/MSBuild/Resources/xlf/Strings.ja.xlf

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

5 changes: 5 additions & 0 deletions src/MSBuild/Resources/xlf/Strings.ko.xlf

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

5 changes: 5 additions & 0 deletions src/MSBuild/Resources/xlf/Strings.pl.xlf

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

5 changes: 5 additions & 0 deletions src/MSBuild/Resources/xlf/Strings.pt-BR.xlf

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

5 changes: 5 additions & 0 deletions src/MSBuild/Resources/xlf/Strings.ru.xlf

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

5 changes: 5 additions & 0 deletions src/MSBuild/Resources/xlf/Strings.tr.xlf

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

5 changes: 5 additions & 0 deletions src/MSBuild/Resources/xlf/Strings.zh-Hans.xlf

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

5 changes: 5 additions & 0 deletions src/MSBuild/Resources/xlf/Strings.zh-Hant.xlf

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

50 changes: 37 additions & 13 deletions src/MSBuild/XMake.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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,
Expand All @@ -1217,7 +1220,7 @@ internal static bool BuildProject(
toolsetDefinitionLocations,
cpuCount,
onlyLogCriticalEvents,
loadProjectsReadOnly: !preprocessOnly,
loadProjectsReadOnly: !isPreprocess,
useAsynchronousLogging: true,
reuseProjectRootElementCache: s_isServerNode);

Expand All @@ -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);
Expand All @@ -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);
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
Copy link
Member

Choose a reason for hiding this comment

The 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"

Copy link
Contributor Author

Choose a reason for hiding this comment

The 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

Copy link
Member

Choose a reason for hiding this comment

The 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);

Expand Down