locked
Missing Microsoft.CodeDom.Providers.DotNetCompilerPlatform.props file RRS feed

  • Question

  • User695372294 posted

    I recently updated a simple 2-page website using the VB.Net version of Microsoft's ASP.NET Web Application template and then upgraded it to use Bootstrap 4 instead of Bootstrap 3, plus other changes. Earlier today, I exported a template from this project to help me to update other sites in a similar manner. However, the first new project I created using my custom template is giving me the following error.

    This project references NuGet package(s) that are missing on this computer. Use NuGet Package Restore to download them.  For more information, see http://go.microsoft.com/fwlink/?LinkID=322105. The missing file is packages\Microsoft.CodeDom.Providers.DotNetCompilerPlatform.2.0.1\build\net46\Microsoft.CodeDom.Providers.DotNetCompilerPlatform.props.

    I used the NuGet Package Manager in VS 2019 to update the Microsoft.CodeDom.Providers.DotNetCompilerPlatform to the latest level, but that didn't fix the problem. I then tried the suggestion to use NuGet Package Restore, but this also had no effect. For reasons I don't understand, the bin\roslyn folder is empty. Perhaps that has some bearing on my problem, but I have failed to find a way to fix that.

    Any guidance would be much appreciated.

    Wednesday, September 23, 2020 4:51 PM

Answers

  • User-1330468790 posted

    Hi haggis999,

     

    Have you checked the url provided in the error message?

     

    Possible Reasons: 

    If so, you might be able to see the reason for this error:

    1. This error occurs when you attempt to build a project that contains references to one or more NuGet packages, but those packages are not presently installed on the computer or in the project.

    2. This situation commonly occurs when you obtain the project's source code from source control or another download. Packages are typically omitted from source control or downloads because they can be restored from package feeds like nuget.org (see Packages and source control). Including them would otherwise bloat the repository or create unnecessarily large .zip files.

    3. The error can also happen if your project file contains absolute paths to package locations, and you move the project.

    I suspect that the third one is the cause of your problem.

     

    Solutions:  

    You could find the official explanation and solution for this error here => This project references NuGet package(s) that are missing on this computer

     

    Another Suggestion: 

    Besides, you could try another simpler solution from here => StackOverflow: This project references NuGet package(s) that are missing on this computer

    Since the error message comes from .csproj file

    <Import Project="$(SolutionDir)\.nuget\NuGet.targets" Condition="Exists('$(SolutionDir)\.nuget\NuGet.targets')" />
    <Target Name="EnsureNuGetPackageBuildImports" BeforeTargets="PrepareForBuild">
      <PropertyGroup>
        <ErrorText>This project references NuGet package(s) that are missing on this computer. Enable NuGet Package Restore to download them.  For more information, see http://go.microsoft.com/fwlink/?LinkID=322105. The missing file is {0}.</ErrorText>
      </PropertyGroup>
      <Error Condition="!Exists('$(SolutionDir)\.nuget\NuGet.targets')" Text="$([System.String]::Format('$(ErrorText)', '$(SolutionDir)\.nuget\NuGet.targets'))" />
    </Target>

    You could directly remove the above following the steps:

    1. Right click on project. Unload Project.
    2. Right click on project. Edit csproj.
    3. Remove the part from the file. Save.
    4. Right click on project. Reload Project.

     

    Hope this can help you.

    Best regards,

    Sean

     

    • Marked as answer by Anonymous Thursday, October 7, 2021 12:00 AM
    Thursday, September 24, 2020 6:20 AM

All replies

  • User-1330468790 posted

    Hi haggis999,

     

    Have you checked the url provided in the error message?

     

    Possible Reasons: 

    If so, you might be able to see the reason for this error:

    1. This error occurs when you attempt to build a project that contains references to one or more NuGet packages, but those packages are not presently installed on the computer or in the project.

    2. This situation commonly occurs when you obtain the project's source code from source control or another download. Packages are typically omitted from source control or downloads because they can be restored from package feeds like nuget.org (see Packages and source control). Including them would otherwise bloat the repository or create unnecessarily large .zip files.

    3. The error can also happen if your project file contains absolute paths to package locations, and you move the project.

    I suspect that the third one is the cause of your problem.

     

    Solutions:  

    You could find the official explanation and solution for this error here => This project references NuGet package(s) that are missing on this computer

     

    Another Suggestion: 

    Besides, you could try another simpler solution from here => StackOverflow: This project references NuGet package(s) that are missing on this computer

    Since the error message comes from .csproj file

    <Import Project="$(SolutionDir)\.nuget\NuGet.targets" Condition="Exists('$(SolutionDir)\.nuget\NuGet.targets')" />
    <Target Name="EnsureNuGetPackageBuildImports" BeforeTargets="PrepareForBuild">
      <PropertyGroup>
        <ErrorText>This project references NuGet package(s) that are missing on this computer. Enable NuGet Package Restore to download them.  For more information, see http://go.microsoft.com/fwlink/?LinkID=322105. The missing file is {0}.</ErrorText>
      </PropertyGroup>
      <Error Condition="!Exists('$(SolutionDir)\.nuget\NuGet.targets')" Text="$([System.String]::Format('$(ErrorText)', '$(SolutionDir)\.nuget\NuGet.targets'))" />
    </Target>

    You could directly remove the above following the steps:

    1. Right click on project. Unload Project.
    2. Right click on project. Edit csproj.
    3. Remove the part from the file. Save.
    4. Right click on project. Reload Project.

     

    Hope this can help you.

    Best regards,

    Sean

     

    • Marked as answer by Anonymous Thursday, October 7, 2021 12:00 AM
    Thursday, September 24, 2020 6:20 AM
  • User695372294 posted

    Sean Fang

    Have you checked the url provided in the error message?   

    ................................  

    Another Suggestion: 

    Besides, you could try another simpler solution from here => StackOverflow: This project references NuGet package(s) that are missing on this computer

    Since the error message comes from .csproj file

    <Import Project="$(SolutionDir)\.nuget\NuGet.targets" Condition="Exists('$(SolutionDir)\.nuget\NuGet.targets')" />
    <Target Name="EnsureNuGetPackageBuildImports" BeforeTargets="PrepareForBuild">
      <PropertyGroup>
        <ErrorText>This project references NuGet package(s) that are missing on this computer. Enable NuGet Package Restore to download them.  For more information, see http://go.microsoft.com/fwlink/?LinkID=322105. The missing file is {0}.</ErrorText>
      </PropertyGroup>
      <Error Condition="!Exists('$(SolutionDir)\.nuget\NuGet.targets')" Text="$([System.String]::Format('$(ErrorText)', '$(SolutionDir)\.nuget\NuGet.targets'))" />
    </Target>

    You could directly remove the above following the steps:

    1. Right click on project. Unload Project.
    2. Right click on project. Edit csproj.
    3. Remove the part from the file. Save.
    4. Right click on project. Reload Project.

    Hi Sean,
    I'm totally new to anything related to NuGet, so many thanks for that very detailed and rapid response.

    The url in the error message was what had originally pointed me to using Package Restore. That same 'Troubleshooting package restore errors' page had also previously highlighted an earlier issue with a hard-coded path in my project file, so that wasn't the cause of my current problem.

    However, your suggestion to delete the error-related section of my project file (vsproj in my case) fixed the missing file issue. Thanks again for pointing me in the right direction.

    A rebuild now proceeded much further than before which then highlighted a couple of new errors with missing references. However, I fixed these by using the NuGet Package Manager to uninstall and reinstall the relevant packages.

    Thursday, September 24, 2020 9:04 AM