-
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
Issue error or warning if BaseIntermediateOutputPath is modified after it's used to calculate MSBuildProjectExtensionsPath #803
Comments
@rainersigwald @AndyGerlicher What do you folks think about adding a warning or error for this in MSBuild compared to doing it in the .NET SDK? |
I'd filed dotnet/msbuild#1603 in MSBuild about this. |
I don't see a good way to catch this in common targets alone. The usual (admittedly terrible) approach to this sort of check is to set a shadow property (maybe In the past, folks have brought up notions like write-once or defaulted properties (I couldn't find an issue for this, so I filed dotnet/msbuild#1673). That could help here but would be a serious language change. |
That doesn't seem to be true. I think the first point of use is in Microsoft.Common.props. Perhaps instead of having a shadow property, we could simply compare against <MSBuildProjectExtensionsPath Condition="'$([System.IO.Path]::IsPathRooted($(MSBuildProjectExtensionsPath)))' == 'false'">$([System.IO.Path]::Combine('$(MSBuildProjectDirectory)', '$(MSBuildProjectExtensionsPath)'))</MSBuildProjectExtensionsPath> |
…sed in Microsoft.Common.props Fixes dotnet#803
MSBuild has a PR for this: dotnet/msbuild#3059 |
Fixed with NuGet/NuGet.Client#2131 and dotnet/msbuild#3059 |
…0190724.11 (dotnet#803) - Microsoft.AspNetCore.Mvc.Analyzers - 3.0.0-preview8.19374.11 - Microsoft.AspNetCore.Mvc.Api.Analyzers - 3.0.0-preview8.19374.11 - Microsoft.AspNetCore.Analyzers - 3.0.0-preview8.19374.11 - Microsoft.AspNetCore.Components.Analyzers - 3.0.0-preview8.19374.11
Filing this in the SDK repo for now, though we may want to do this in MSBuild itself.
If you try to override the
BaseIntermediateOutputPath
property in a project that uses the<Project Sdk="Microsoft.NET.Sdk">
syntax, you will be setting the property after it's already been used to calculate theMSBuildProjectExtensionsPath
property, which is where the auto-generated NuGet .props and .targets files are imported from. So you won't get any imports from NuGet packages.The solution to this is to set the
BaseIntermediateOutputPath
in a Directory.Import.props file, which gets evaluated beforehand, or not to use theSdk
attribute on the project and instead have a pair of .props and .targets imports in the project to import from the Sdk, and to set theBaseIntermediateOutputPath
before the .props import.This is likely to be a common issue people run into, and it will not be obvious what is wrong or how to fix it. So we should consider detecting that the
BaseIntermediateOutputPath
property was modified after it was used to calculateMSBuildProjectExtensionsPath
, and generate an error (or at least a warning).Related issue for us to fix this for the SDK build itself: #802
The text was updated successfully, but these errors were encountered: