Skip to content

Fix issue with list of warnings or errors to treat differently can be added to the list multiple times#2671

Merged
jeffkl merged 5 commits intodotnet:masterfrom
jeffkl:fix-2667
Nov 6, 2017
Merged

Fix issue with list of warnings or errors to treat differently can be added to the list multiple times#2671
jeffkl merged 5 commits intodotnet:masterfrom
jeffkl:fix-2667

Conversation

@jeffkl
Copy link
Copy Markdown
Contributor

@jeffkl jeffkl commented Oct 26, 2017

When building two or more projects in the same build episode, the list of warnings to treat as errors or warnings to treat as messages is parsed multiple times.

This fixes the issue by checking if the list is already populated for a given project instance.

Fixes #2667

… added to the list multiple times

When building two or more projects in the same build episode, the list of warnings to treat as errors or warnings to treat as messages is parsed multiple times.

This fixes the issue by checking if the list is already populated for a given project instance.

Fixes dotnet#2667
Copy link
Copy Markdown
Member

@radical radical left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It would be nice to explain in the commit message why it is expected and OK for these to be added more than once.

try
{
ObjectModelHelpers.CreateFileInTempProjectDirectory("project1.proj", $@"
<Project ToolsVersion=""msbuilddefaulttoolsversion"" xmlns=""msbuildnamespace"">
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Do we need the ToolsVersion and xmlns attributes here?

/// https://github.com/Microsoft/msbuild/issues/2667
/// </summary>
[Fact]
public void TreatWarningsAsMessagesWhenBuildingSameProjectMultipleTimes()
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Maybe another test for WarningsAsErrors, to be thorough?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done

{
try
{
ObjectModelHelpers.CreateFileInTempProjectDirectory("project1.proj", $@"
Copy link
Copy Markdown
Contributor

@cdmihai cdmihai Oct 26, 2017

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nit: Consider using the brand new TestEnvironment for test isolation :)

Copy link
Copy Markdown
Contributor

@cdmihai cdmihai left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM pending on @radical's suggestions

CreatedFiles = Helpers.CreateFilesInDirectory(TestRoot, files);
}

internal MockLogger BuildProjectExpectFailure(IDictionary<string, string> globalProperties = null, string toolsVersion = null)
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nitpicking a bit, I guess. Why internal and not public? This is a tests only class.

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Also, are these two wrappers useful? And it's not obvious from the name that this would return a logger.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

MockLogger is internal so the methods had to be internal as well. These methods reflect other functionality we have in ObjectModelHelpers

@AndyGerlicher
Copy link
Copy Markdown
Contributor

As-is this would target 15.6. That ok? We can go through escrow if needed for 15.5.

@jeffkl
Copy link
Copy Markdown
Contributor Author

jeffkl commented Oct 26, 2017

@radical you mention this is failing NuGet restore in some cases. Do you know how big of an impact we're going to see? I'm assuming its low since you're the first person to report it...

@radical
Copy link
Copy Markdown
Member

radical commented Oct 27, 2017

@jeffkl I am able to reproduce this with a simple solution which has project A depending on a library project B. And B has <MSBuildWarningsAsMessages>MSB9001</MSBuildWarningsAsMessages>. msbuild /t:Restore fails for such a solution! Note that I didn't even have to add any nuget references to this! I think hitting this might be not be rare for anyone using MSBuildWarningsAsMessages. Though usage of MSBuildWarningsAsMessages might not be that common itself, I don't know!

@jeffkl
Copy link
Copy Markdown
Contributor Author

jeffkl commented Oct 27, 2017

Thanks @radical. We're going to attempt to get this in 15.5 pending approval

@jeffkl jeffkl merged commit 14dabf5 into dotnet:master Nov 6, 2017
@jeffkl jeffkl deleted the fix-2667 branch November 6, 2017 19:24
cdmihai pushed a commit to cdmihai/msbuild that referenced this pull request Nov 6, 2017
… added to the list multiple times (dotnet#2671)

* Fix issue with list of warnings or errors to treat differently can be added to the list multiple times

When building two or more projects in the same build episode, the list of warnings to treat as errors or warnings to treat as messages is parsed multiple times.

This fixes the issue by checking if the list is already populated for a given project instance.

Fixes dotnet#2667
AndyGerlicher pushed a commit that referenced this pull request Nov 6, 2017
… added to the list multiple times (#2671) (#2704)

* Fix issue with list of warnings or errors to treat differently can be added to the list multiple times

When building two or more projects in the same build episode, the list of warnings to treat as errors or warnings to treat as messages is parsed multiple times.

This fixes the issue by checking if the list is already populated for a given project instance.

Fixes #2667
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Build failure with use of MSBuildWarningsAsMessages

5 participants