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

Setting IncludePackageReferencesDuringMarkupCompilation with a custom BaseIntermediateOutputPath causes build to fail #4067

Closed
nick-beer opened this issue Jan 24, 2021 · 4 comments

Comments

@nick-beer
Copy link

  • .NET Core Version: 5.0.102

Problem description:
I tried following the suggestion in #3963 in order to pull in a source generator nuget to a wpf project. Upon doing so (setting IncludePackageReferencesDuringMarkupCompilation to true), my build fails with the following:

C:\Program Files\dotnet\sdk\5.0.102\Sdks\Microsoft.NET.Sdk\targets\Microsoft.PackageDependencyResolution.targets(241,5):
error NETSDK1004: Assets file 'C:\Dev\pkgref-bugs\Objects\wpf-app_smqwgw3w_wpftmp\project.assets.json' not found.
Run a NuGet package restore to generate this file. [C:\Dev\pkgref-bugs\wpf-app\wpf-app_smqwgw3w_wpftmp.csproj]

I noticed that if I stop using a custom BaseIntermediateOutputPath for my projects, then I'm able to build successfully.

Expected behavior:
I should be able to use source generators with wpf applications and use a custom BaseIntermediateOutputPath

Minimal repro:

  • Add a package reference to a source generator in a wpf project
  • Set the IncludePackageReferencesDuringMarkupCompilation property to be true
  • Create a Directory.Build.props file to set BaseIntermediateOutputPath. I used ..\Objects\$(MSBuildProjectName)
@ryalanms
Copy link
Member

Hi @nick-beer

#4009

Apologies for the messaging on this feature. The path changes were separated from the source generator support to meet the risk bar for 5.0.2 servicing, but were added back as an opt-in feature for 5.0.3. The changes are in master and will be in 5.0.3 when it ships. Thanks.

@nick-beer
Copy link
Author

@ryalanms - thanks for the information. I'll be looking forward to 5.0.3.

Glad to hear it won't matter long term, but in the meantime I was able to move forward by making the intermediate output path for the WPF inner build match that of the standard build.

<IsWpfInnerTempProject Condition="$(MSBuildProjectName.EndsWith('_wpftmp'))">true</IsWpfInnerTempProject>
<BasePathProjectName>$(MSBuildProjectName)</BasePathProjectName>
<BasePathProjectName Condition="'$(IsWpfInnerTempProject)' == 'true'">$([System.Text.RegularExpressions.Regex]::Replace($(MSBuildProjectName), '_[^_]+_wpftmp', '', System.Text.RegularExpressions.RegexOptions.IgnoreCase))</BasePathProjectName>
<BaseIntermediateOutputPath>$(ObjectDirectory)\NetCore\$(BasePathProjectName)</BaseIntermediateOutputPath>

@ryalanms
Copy link
Member

ryalanms commented Feb 1, 2021

Please reactivate if you see any issues with 5.0.3. Thanks.

@ryalanms ryalanms closed this as completed Feb 1, 2021
@nick-beer
Copy link
Author

@ryalanms - I'm still seeing this with sdk 5.0.201, but I'm not able to reopen this issue.

I've created a simple set of projects that reproduce the issue - you can get it here.

sharwell added a commit to sharwell/MSBuildStructuredLog that referenced this issue Mar 12, 2021
sharwell added a commit to sharwell/MSBuildStructuredLog that referenced this issue Mar 12, 2021
sharwell added a commit to sharwell/MSBuildStructuredLog that referenced this issue Mar 12, 2021
filipnavara pushed a commit to filipnavara/MSBuildStructuredLog that referenced this issue Sep 29, 2021
@ghost ghost locked as resolved and limited conversation to collaborators Apr 10, 2022
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants