-
Notifications
You must be signed in to change notification settings - Fork 1.4k
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
[Feature Request]: The warning in the WriteCodeFragment task should be changed to report the name of the attribute type whose definition it did not find. #10007
Comments
Get a more detailed MSBuild log and check what is being passed to the AssemblyAttributes parameter of the WriteCodeFragment task. I think WriteCodeFragment was unable to locate the definition of some attribute type that is listed there, and thus could not check the parameter types of the constructors. If the type is defined in some assembly that WriteCodeFragment does not search, I don't think there is a way to tell WriteCodeFragment from where to load it; but you can instead add item metadata to specify the type of the parameter so that WriteCodeFragment won't have to find it by reflection. This still deserves fixes in .NET:
|
I have just set the build mode to Diagnostic and this is what I can find that is relevant:
From Package / General in Project Settings: |
I'd blame Microsoft.Extensions.Configuration.UserSecrets.UserSecretsIdAttribute; that seems unlikely to be found by WriteCodeFragment. This could be changed to set the parameter type metadata if the MSBuild version is high enough that its WriteCodeFragment task supports such metadata and won't treat it as another parameter. |
This is the version that I have:
Note that |
I meant, if the targets file in the Microsoft.Extensions.Configuration.UserSecrets package is modified, then that should preferably be done in such a way that compatibility with older versions of MSBuild doesn't break. The value of the UserSecretsIdAttribute does not matter for the "Could not infer" message; only the attribute type matters. But the user secrets ID isn't very secret anyway; anybody to whom you distribute the executable can read it from the assembly attributes, or capture it by monitoring the names of opened files (e.g. |
@KalleOlaviNiemitalo |
Looking at the message again
This doesn't even say "warning" so it's just a message. I don't think you need to do anything to it. If you want to get rid of it anyway, then one way would be to set <GenerateUserSecretsAttribute>false</GenerateUserSecretsAttribute> in your project to prevent the attribute from being generated, and instead add it yourself, in one of these places:
As a user of MSBuild, I'd like to keep this issue open for the feature request
but if you prefer closing this one, then I can file a separate one for that. |
We can leave it open. 👍 |
@KalleOlaviNiemitalo |
Issue Description
Not sure if this is a bug as such, but had to pick a template all the same. I set my compiler output to Normal and noticed this output:
Why does it say:
I have tried to find an explanation, but it is a little over my head. Eg:
#2281
This is a C# .NET8.0 Console App build with latest version of Visual Stduio 2022.
Steps to Reproduce
I can't get this to reproduce with an empty C# console project so I am not sure of the steps to reproduce.
Expected Behavior
I don't expect to see this warning.
Actual Behavior
I am getting this warning.
Analysis
Initially I thought it was because my version numbers for
n.n.n
and I changed them ton.n.n.n
. It it was not the reason.Versions & Configurations
MSBuild version 17.9.8+b34f75857 for .NET Framework
17.9.8.16306
Windows 11 x64
The text was updated successfully, but these errors were encountered: