Skip to content
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

Permit a task to disable MSB4181 Fixes #5203 #5207

Merged
merged 4 commits into from
Apr 28, 2020

Conversation

Forgind
Copy link
Member

@Forgind Forgind commented Mar 27, 2020

Using IBuildEngine7, one can disable MSB4132 in a task.

Fixes #5203
Also fixes #2036

Copy link

@sae42 sae42 left a comment

Choose a reason for hiding this comment

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

A few places are returning IBuildEngine6 rather than IBuildEngine7.

/// <summary>
/// Retrieves the <see cref="IBuildEngine7" /> version of the build engine interface provided by the host.
/// </summary>
public IBuildEngine6 BuildEngine7 => (IBuildEngine7)BuildEngine;
Copy link

Choose a reason for hiding this comment

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

Shouldn't this return IBuildEngine7?

@@ -197,6 +197,7 @@ public abstract partial class Task : Microsoft.Build.Framework.ITask
public Microsoft.Build.Framework.IBuildEngine4 BuildEngine4 { get { throw null; } }
public Microsoft.Build.Framework.IBuildEngine5 BuildEngine5 { get { throw null; } }
public Microsoft.Build.Framework.IBuildEngine6 BuildEngine6 { get { throw null; } }
public Microsoft.Build.Framework.IBuildEngine6 BuildEngine7 { get { throw null; } }
Copy link

Choose a reason for hiding this comment

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

Shouldn't this return IBuildEngine7?

@@ -352,6 +352,7 @@ public abstract partial class Task : Microsoft.Build.Framework.ITask
public Microsoft.Build.Framework.IBuildEngine4 BuildEngine4 { get { throw null; } }
public Microsoft.Build.Framework.IBuildEngine5 BuildEngine5 { get { throw null; } }
public Microsoft.Build.Framework.IBuildEngine6 BuildEngine6 { get { throw null; } }
public Microsoft.Build.Framework.IBuildEngine6 BuildEngine7 { get { throw null; } }
Copy link

Choose a reason for hiding this comment

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

Shouldn't this return IBuildEngine7?

/// <summary>
/// Enables or disables emitting MSB4134 to log when a task fails without logging errors
/// </summary>
public void SetEnableMSB4134(bool enableError)
Copy link
Member

Choose a reason for hiding this comment

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

Why is this an explicit set method rather than a setter?

Copy link
Member Author

Choose a reason for hiding this comment

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

You mean a property with {get; set;}? I don't think you can access that with reflection.

Copy link
Member

Choose a reason for hiding this comment

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

You can, with Type.GetProperty

@@ -1064,8 +1064,8 @@
</comment>
</data>
<data name="TaskReturnedFalseButDidNotLogError">
<value>MSB4132: The "{0}" task returned false but did not log an error.</value>
<comment>{StrBegin="MSB4132: "}</comment>
<value>MSB4134: The "{0}" task returned false but did not log an error.</value>
Copy link
Member

Choose a reason for hiding this comment

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

This appears to have been used, too:

MSB4134: DefaultToolsVersion cannot be set after a project has been loaded into the Engine.

That's coming entirely from the Deprecated\Engine folder, but we still shouldn't recycle.

/// </summary>
public interface IBuildEngine7 : IBuildEngine6
{
public void SetEnableMSB4134(bool errorEnabled);
Copy link
Member

Choose a reason for hiding this comment

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

Don't include the error code in the name of this method. Give it a descriptive name instead, like maybe

Suggested change
public void SetEnableMSB4134(bool errorEnabled);
public void AllowFailureWithoutError(bool errorEnabled);

?

@@ -93,7 +93,7 @@ public void AssemblyFoldersFromConfigPlatformSpecificAssemblyFirstTest()
}

[Fact]
public void AasemblyFoldersFromConfigNormalizeNetFrameworkVersion()
Copy link
Member

Choose a reason for hiding this comment

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

Please separate this into its own PR.

Copy link
Member

Choose a reason for hiding this comment

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

Ping

@Forgind Forgind changed the title Permit a task to disable MSB4132 Fixes #5203 Permit a task to disable MSB4181 Fixes #5203 Apr 3, 2020
@rainersigwald
Copy link
Member

Team triage: we'd like to reserve IBuildEngine7 for some changes going into 16.7 that are already planned. Let's delay this change until then as well.

@rainersigwald rainersigwald added this to the MSBuild 16.7 milestone Apr 3, 2020
@sae42
Copy link

sae42 commented Apr 6, 2020

@rainersigwald If this fix has to be deferred to 16.7 is there any chance of reverting the original change that caused this issue until 16.7 also? Failing that, please at least correct the error code so that it will be consistent between releases.

Copy link
Member

@rainersigwald rainersigwald left a comment

Choose a reason for hiding this comment

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

Can you rebase onto current master instead of merging?

@@ -93,7 +93,7 @@ public void AssemblyFoldersFromConfigPlatformSpecificAssemblyFirstTest()
}

[Fact]
public void AasemblyFoldersFromConfigNormalizeNetFrameworkVersion()
Copy link
Member

Choose a reason for hiding this comment

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

Ping

This adds back support for logging an error when a task returns false
without logging an error. This was originally added in dotnet#4940 but was
reverted because of multiple difficulties.
Copy link
Member

@rainersigwald rainersigwald left a comment

Choose a reason for hiding this comment

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

Merge please, don't squash.

@Forgind Forgind merged commit f4dacba into dotnet:master Apr 28, 2020
@Forgind Forgind deleted the MSB4132-opt-out branch April 28, 2020 21:20
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
3 participants