简体   繁体   中英

nuget packages folder is created in solution level and project level hint path not able to find it

MVC project is unable to find the nuget package and throwing error.The missing file is packages\\Microsoft.CodeDom.Providers.DotNetCompilerPlatform.2.0.1\\build\\net46\\Microsoft.CodeDom.Providers.DotNetCompilerPlatform.props.The packages folder is created at solution level and hint path is used in csproj as below, Any suggestions? Moving the packages folder from solution level to the project level works, but i do not want to manually do it every time as this mvc project is dynamically created and on F5 I would like the build to be succeeded.

 <ItemGroup>
    <Reference Include="Microsoft.CodeDom.Providers.DotNetCompilerPlatform">
      <HintPath>packages\Microsoft.CodeDom.Providers.DotNetCompilerPlatform.2.0.1\lib\net45\Microsoft.CodeDom.Providers.DotNetCompilerPlatform.dll</HintPath>
    </Reference>
  </ItemGroup>

This is path-related issue. Add $(SolutionDir) before packages\\xxx\\xxx to make sure msbuild will search the assembly from packages folder in Solution level.

It should be:

  <ItemGroup>
    <Reference Include="Microsoft.CodeDom.Providers.DotNetCompilerPlatform">
      <HintPath>$(SolutionDir)packages\Microsoft.CodeDom.Providers.DotNetCompilerPlatform.2.0.1\lib\net45\Microsoft.CodeDom.Providers.DotNetCompilerPlatform.dll</HintPath>
    </Reference>
  </ItemGroup>

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