简体   繁体   中英

MSBuildProjectExtensionsPath MSBuild Property Could Not be Found When trying to Manage Nuget Packages

I've encountered a weird error today when trying to manage nuget packages on a unit test project in my solution:

没有财产:(

I took a look at the documentation for this property: https://docs.microsoft.com/en-us/visualstudio/msbuild/customize-your-build?view=vs-2019 and it mentions that this property is part of a props or a target file. My solution does not have one of these. I went ahead and modified the csproj to add the property: <MSBuildProjectExtensionsPath /> to the appropriate build propertygroup, and it didn't detect it either. I looked at another project that lets me work with nuget packages successfully and it doesn't have the property at all.

Anyone know what's going on?

您可能不小心从项目文件中删除了以下行:

  <Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />

I gave up trying to figure it out. I created a new project and put in my code files/references.

MSBuildProjectExtensionPath is defined at Microsoft.Common.props

<MSBuildProjectExtensionsPath>$([MSBuild]::EnsureTrailingSlash($([MSBuild]::ValueOrDefault('$(MSBuildProjectExtensionsPath)', '$(BaseIntermediateOutputPath)'))))</MSBuildProjectExtensionsPath>

So you may miss to import that file in your project begining.

<Import Project="$(MSBuildExtensionsPath)$(MSBuildToolsVersion)\\Microsoft.Common.props" Condition="Exists('$(MSBuildExtensionsPath)$(MSBuildToolsVersion)\\Microsoft.Common.props')" />

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM