-
Notifications
You must be signed in to change notification settings - Fork 1.1k
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
MSB4181 vis-a-vis custom MSBuild task targets #14292
Comments
@mwpowellhtx The bavtest project you attached builds for me with SDK 3.1.403 and 5.0.100 and I do not see that MSB error. Can you provide more details on the error you're seeing or provide the binlong In general, every SDK can target downlevel and we recommend users use the most up to date version of the SDK. |
Do you see the effect of BAV? Since the most recent VS2019 update, I ran it, and now I do not see that BAV is being invoked whatsoever. In the test case, we expect that an To verify, I edited the installed BAV targets to see if I was getting any invokation whatsoever, and it would seem I am not. <Target Name="DebuggingBav">
<Message Text="BAV is attempting to run" Importance="high" />
</Target>
<!-- This works perfectly in the single-target scenario, but we need to condition our response based on whether TargetFrameworks was there. -->
<Target Name="BumpAssemblyVersionsBeforeBuild" AfterTargets="DebuggingBav" BeforeTargets="BeforeBuild" Condition="'$(TargetFrameworks)' == ''">
<CallTarget Targets="GeneralBumpAssemblyVersions" />
</Target>
<!-- BeforeBuild occurs for each of the targets individually in a multi-target scenario, so we must Bump relative to the Outer loop Dispatch. -->
<Target Name="BumpAssemblyVersionsBeforeDispatchToInnerBuilds" AfterTargets="DebuggingBav" BeforeTargets="DispatchToInnerBuilds" Condition="'$(TargetFrameworks)' != ''">
<CallTarget Targets="GeneralBumpAssemblyVersions" />
</Target> Which would lead me to believe that, best case, the targets are completely different for |
@marcpopMSFT For comparison and contrast, I added a class library project, which does at least try to invoke the version bump task. That I can determine in this instance, MSBuild is failing to connect the properties with the task variables properly, specifically the In any event, I just need some constructive, useful feedback there so I can respond accordingly and make it right. |
@marcpopMSFT I promise you BAV ran successfully under previous runtimes, |
@marcpopMSFT So in summary, seems to me there are at least two issues piling on there. First, WinForms MSBuild targets are completely different, are not connecting with the BAV targets. Second, a possible MSBuild issue, failing to connect the build task with its |
I still have not been able to trigger MSB4181. I can confirm through the binlog that BumpAssemblyVersionsBeforeBuild is being run. You should use I'm not familiar with the BumpAssemblyVersion plugin to MSBuild but I have been able to confirm it working in some scenarios and not in others. If I use the 5.0 SDK (that released today) and switch to importing the Microsoft.NET.Sdk, then I see the assembly version being bumped even for a 3.1 targeted application. If I use the 3.1.403 SDK or 5.0 SDK but import Microsoft.NET.Sdk.WindowsDesktop instead, I see that BumpAssemblyVersionsBeforeBuild is run but I neither see the error nor does it appear to succeed. So my suggestion is upgrade to the 5.0 SDK, switch your first line to be , and see if that works: |
@marcpopMSFT Version bumps work fine I think as long as the project In terms of inner and outer task loops, yes, I tested in a variety of scenarios, single targeting and multi-targeting, in order to establish which targets would be invoked so that I could bump a single time, depending on the scenario. Mainly, for multi scenarios, I want to prohibit outcomes that would bump multiple times. I think I was successful in that.
I think this is because as I stated above, MSBuild is not relaying the spec variables properly when the target is invoked. I learned this after a bit of debugging output from the perspective of the CSharp build task code determining what's what, are targets even being invoked, do they see the variables being relayed properly, etc. So, in summary, I think we are closer to mutual comprehension on the issue, let alone possible root causes, remedial actions, etc, but we're not quite there yet. |
I can confirm through the binlog that the |
@marcpopMSFT Ah! 💡 Totally fogotten about that line, appreciate the code review. I'll have a closer look at it. |
Will go ahead and close this one. Appreciate the review once again. We think that is probably the root cause and are pursuing as such. |
Borderline to do with MSBuild as much as it is the SDK.
I have a scenario with a
netcoreapp3.1
targeted (WinForms, i.e.WinExe
) project that is generating anMSB4181
error.Generally speaking, as tooling, the bumps work, has been proven to do so over a range of scenarios from netstandard to netcoreapp to classical desktop .NET Framework scenarios; but in this scenario we are bumping into the
MSB4181
.Literally the project in question is:
I have discovered the SDKs in my syste mare currently:
However, I think that probably the build is happening under
3.1.402
, which, from at least a couple of other items, is thought to be that the SDK itself broke something along the way, with at least one workaround supposing global.json. Possibly, also,runtimeconfig.json
may also be used to workaround the issue.Assuming either or both of these would successfully workaround the issue, the question for me then is, to which SDK. I don't think my custom MSBuild task assembly necessarily cares what that is, as long as there is support for
netstandard2.0
. Thinking forward, then there is also the problem of the hole in the middle; what to do with instances of the3.1.402
SDK, which apparently cause the issue. Maybe this is already supported byglobal.json
and/orruntimeconfig.json
, but I am less familiar with those protocols.Attached is a repro of the issue. Observing the results of the build in a couple of local BAV turns, it seems like the tooling does try to perform what it needs to perform, however, MSBuild is failing to relay the item specs properly via its targets, which tells me that probably something integration-wise broke in terms of MSBuild more than anything else.
bavtest.zip
The text was updated successfully, but these errors were encountered: