microsoft / MSBuildSdks

MSBuild project SDKs
MIT License
460 stars 82 forks source link

CopyOnWrite: preserve MSB3026 and warning compatibility #494

Closed KirillOsenkov closed 1 year ago

KirillOsenkov commented 1 year ago

CopyOnWrite needs to preserve the exact warnings the classical Copy task emits. For instance, classical Copy emits MSB3026 when the file is locked, in these two places:

https://github.com/dotnet/msbuild/blob/c36a54ed3308d1516ffe1a86b9086c42e4ca996f/src/Tasks/Copy.cs#L872-L874

https://github.com/dotnet/msbuild/blob/c36a54ed3308d1516ffe1a86b9086c42e4ca996f/src/Tasks/Copy.cs#L898-L900

If we don't replicate this, builds will fail when converted to CopyOnWrite.

For example we have <MSBuildWarningsAsMessages>MSB3026</MSBuildWarningsAsMessages> that is suppressed just fine normally, but stopped working after we started using CopyOnWrite.

@inthemedium @erikmav

KirillOsenkov commented 1 year ago

This is where we currently log MSB3021 instead of MSB3026: https://github.com/microsoft/MSBuildSdks/blob/c80b0340f4748fb667a48ff4d4f3e61a133dff46/src/CopyOnWrite/Copy.cs#L761

KirillOsenkov commented 1 year ago

See also #493

erikmav commented 1 year ago

The noted MSB3021 code above is consistent with the same code path in MSBuild, which emits Copy.Error resource with this string value. Not updating.

<value>MSB3021: Unable to copy file "{0}" to "{1}". {2}</value>