Skip to content

Commit

Permalink
Enhance msb4064 unexpected task attribute error (#5945)
Browse files Browse the repository at this point in the history
* Improve MSB4064 error message

This commit enhances the MSB4064 error with additional information and
details such as:
 - assembly identity - it's full name containing the token ID, version
   and name.
- Assembly location

The enhanced MSB4064 error message has previously been implemented
without assembly location. It has been added by this commit.
Note that assembly parameter used for the error message has been
replaced with loadedAssembly parameter, due to having the null name
property.
  • Loading branch information
BartoszKlonowski committed Feb 9, 2021
1 parent 31a98dc commit 1a0d8e8
Show file tree
Hide file tree
Showing 16 changed files with 53 additions and 36 deletions.
31 changes: 24 additions & 7 deletions src/Build/BackEnd/TaskExecutionHost/TaskExecutionHost.cs
Expand Up @@ -1098,13 +1098,30 @@ out parameterSet
else
{
// flag an error if we find a parameter that has no .NET property equivalent
_taskLoggingContext.LogError
(
new BuildEventFileInfo(parameterLocation),
"UnexpectedTaskAttribute",
parameterName,
_taskName
);
if (_taskFactoryWrapper.TaskFactoryLoadedType.LoadedAssembly is null)
{
_taskLoggingContext.LogError
(
new BuildEventFileInfo( parameterLocation ),
"UnexpectedTaskAttribute",
parameterName,
_taskName,
_taskFactoryWrapper.TaskFactoryLoadedType.Type.Assembly.FullName,
_taskFactoryWrapper.TaskFactoryLoadedType.Type.Assembly.Location
);
}
else
{
_taskLoggingContext.LogError
(
new BuildEventFileInfo( parameterLocation ),
"UnexpectedTaskAttribute",
parameterName,
_taskName,
_taskFactoryWrapper.TaskFactoryLoadedType.LoadedAssembly.FullName,
_taskFactoryWrapper.TaskFactoryLoadedType.LoadedAssembly.Location
);
}
}
}
catch (AmbiguousMatchException)
Expand Down
2 changes: 1 addition & 1 deletion src/Build/Resources/Strings.resx
Expand Up @@ -1225,7 +1225,7 @@
<comment>{StrBegin="MSB4091: "}</comment>
</data>
<data name="UnexpectedTaskAttribute" xml:space="preserve">
<value>MSB4064: The "{0}" parameter is not supported by the "{1}" task. Verify the parameter exists on the task, and it is a settable public instance property.</value>
<value>MSB4064: The "{0}" parameter is not supported by the "{1}" task loaded from assembly: {2} from the path: {3}. Verify that the parameter exists on the task, the &lt;UsingTask&gt; points to the correct assembly, and it is a settable public instance property.</value>
<comment>{StrBegin="MSB4064: "}</comment>
</data>
<data name="UnexpectedTaskOutputAttribute" xml:space="preserve">
Expand Down
4 changes: 2 additions & 2 deletions src/Build/Resources/xlf/Strings.cs.xlf

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

4 changes: 2 additions & 2 deletions src/Build/Resources/xlf/Strings.de.xlf

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

4 changes: 2 additions & 2 deletions src/Build/Resources/xlf/Strings.en.xlf

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

4 changes: 2 additions & 2 deletions src/Build/Resources/xlf/Strings.es.xlf

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

4 changes: 2 additions & 2 deletions src/Build/Resources/xlf/Strings.fr.xlf

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

4 changes: 2 additions & 2 deletions src/Build/Resources/xlf/Strings.it.xlf

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

4 changes: 2 additions & 2 deletions src/Build/Resources/xlf/Strings.ja.xlf

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

4 changes: 2 additions & 2 deletions src/Build/Resources/xlf/Strings.ko.xlf

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

4 changes: 2 additions & 2 deletions src/Build/Resources/xlf/Strings.pl.xlf

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

4 changes: 2 additions & 2 deletions src/Build/Resources/xlf/Strings.pt-BR.xlf

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

4 changes: 2 additions & 2 deletions src/Build/Resources/xlf/Strings.ru.xlf

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

4 changes: 2 additions & 2 deletions src/Build/Resources/xlf/Strings.tr.xlf

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

4 changes: 2 additions & 2 deletions src/Build/Resources/xlf/Strings.zh-Hans.xlf

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

4 changes: 2 additions & 2 deletions src/Build/Resources/xlf/Strings.zh-Hant.xlf

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

0 comments on commit 1a0d8e8

Please sign in to comment.