All Visual Studio 2017 references in solution project are broken.

slayczar

Member
Joined
Jan 16, 2022
Messages
11
Programming Experience
10+
I have an existing Visual Studio solution with many projects. All projects are using .net version 4.7.1 (no core). The solution is composed of WinForms projects, wcf services projects, asp.net projects and MVC projects. All projects are pointing to the same .dll references. Upon adding an existing, outside asp.net MVC project, all of the references have broken. The project was set to .net 4.6 so I updated to 4.7.1 and the references are still broken. Building the project yeilds a single error:

"This project references NuGet package(s) that are missing on this computer. Use NuGet Package Restore to download them."

I've gone through all of the nuget-added packages and updated them and still the errors remain.
So affter changing the .net version to match all the other projects and double-checking the nuget packages, I've tried the following:

- Clean/close/open/rebuild
- Set nuget package to automatically restore in settings
- Clean/close/clear temp files/open rebuld
- Delete reference, re-add reference using same path as other asp.net MVC project referencing same assembly
- Updating Visual Studio to latest 2017 version
- Remove project/clean/build/re-add project.


Version/install information:

Microsoft Visual Studio Professional 2017
Version 15.9.43
VisualStudio.15.Release/15.9.43+28307.1778
Microsoft .NET Framework
Version 4.8.04084

Installed Version: Professional

Application Insights Tools for Visual Studio Package 8.14.20131.1
Application Insights Tools for Visual Studio

ASP.NET and Web Tools 2017 15.9.04012.0
ASP.NET and Web Tools 2017

ASP.NET Core Razor Language Services 15.8.31590
Provides languages services for ASP.NET Core Razor.

ASP.NET Web Frameworks and Tools 2012 4.0.30625.0
For additional information, visit ASP.NET | Open-source web framework for .NET

ASP.NET Web Frameworks and Tools 2017 5.2.61435.0
For additional information, visit ASP.NET | Open-source web framework for .NET

Azure App Service Tools v3.0.0 15.9.03024.0
Azure App Service Tools v3.0.0

Azure Functions and Web Jobs Tools 15.9.03024.0
Azure Functions and Web Jobs Tools

C# Tools 2.10.0-beta2-63501-03+b9fb1610c87cccc8ceb74a770dba261a58e39c4a
C# components used in the IDE. Depending on your project type and settings, a different version of the compiler may be used.

Common Azure Tools 1.10
Provides common services for use by Azure Mobile Services and Microsoft Azure Tools.

ConvertToDevExtremeCommand Extension 1.0
ConvertToDevExtremeCommand Visual Studio Extension Detailed Info

DevExpress Reporting Extension 1.4
A Visual Studio extension that invokes the Report Designer editor for report definition VSREPX files.

DevExpress Reporting Tools Extension 1.0
Extends Visual Studio with tools required for the Report Designer editor.

DevExpress.DeploymentTool 1.0
A useful tool for deploying DevExpress assemblies.

DevExpress.Win.LayoutAssistant Extension 1.0
DevExpress.Win.LayoutAssistant Visual Studio Extension Detailed Info

JavaScript Language Service 2.0
JavaScript Language Service

Microsoft Azure Tools 2.9
Microsoft Azure Tools for Microsoft Visual Studio 2017 - v2.9.20417.1

Microsoft Continuous Delivery Tools for Visual Studio 0.4
Simplifying the configuration of Azure DevOps pipelines from within the Visual Studio IDE.

Microsoft JVM Debugger 1.0
Provides support for connecting the Visual Studio debugger to JDWP compatible Java Virtual Machines

Microsoft Library Manager 1.0
Install client-side libraries easily to any web project

Microsoft MI-Based Debugger 1.0
Provides support for connecting Visual Studio to MI compatible debuggers

Microsoft Visual Studio Tools for Containers 1.1
Develop, run, validate your ASP.NET Core applications in the target environment. F5 your application directly into a container with debugging, or CTRL + F5 to edit & refresh your app without having to rebuild the container.

NuGet Package Manager 4.6.0
NuGet Package Manager in Visual Studio. For more information about NuGet, visit NuGet documentation.

Office Developer Tools for Visual Studio 2017 ENU 15.0.29728.00
Microsoft Office Developer Tools for Visual Studio 2017 ENU

ProjectServicesPackage Extension 1.0
ProjectServicesPackage Visual Studio Extension Detailed Info

ResourcePackage Extension 1.0
ResourcePackage Visual Studio Extension Detailed Info

ResourcePackage Extension 1.0
ResourcePackage Visual Studio Extension Detailed Info

SQL Server Data Tools 15.1.62002.01090
Microsoft SQL Server Data Tools

TypeScript Tools 15.9.51025.2003
TypeScript Tools for Microsoft Visual Studio

Visual Basic Tools 2.10.0-beta2-63501-03+b9fb1610c87cccc8ceb74a770dba261a58e39c4a
Visual Basic components used in the IDE. Depending on your project type and settings, a different version of the compiler may be used.

Visual Commander 3.1.2
For more information about Visual Commander, see the website at Visual Commander - Modern alternative to Visual Studio macros.

Visual F# Tools 10.2 for F# 4.5 15.8.0.0. Commit Hash: 6e26c5bacc8c4201e962f5bdde0a177f82f88691.
Microsoft Visual F# Tools 10.2 for F# 4.5

Visual Studio Code Debug Adapter Host Package 1.0
Interop layer for hosting Visual Studio Code debug adapters in Visual Studio

Visual Studio Tools for Containers 1.0
Visual Studio Tools for Containers

WiX Toolset Visual Studio Extension 1.0.0.4
WiX Toolset Visual Studio Extension version 1.0.0.4
Copyright (c) .NET Foundation and contributors. All rights reserved.

Workflow Manager Tools 1.0 1.0
This package contains the necessary Visual Studio integration components for Workflow Manager.
 
What is displayed in the Package Manager output pane when you select "Restore Nuget Packages" after right clicking on the solution node in the Solution Explorer?
 
Also, this may help:

Ok I executed this and it replaced all the packages, but all the references in the whole project are still warnings. Also of note, this project was added to an existing Solution that is in Teams DevOps source control; the project that was added does NOT have a lock next to it, but it does show in the source control explorer as checked in.
 

Attachments

  • refs.png
    refs.png
    160.3 KB · Views: 114
Are you sure all those assemblies are all brought in via Nuget? System.dll and System.Data would normally be available on the machine as they come from the Framework SDK.

You may need to crack open the .csproj file and look at each of the assembly references. They may have a hint path pointing to an invalid location, or a valid location but the wrong version of the assemblies. Also, the references may have specific version attributes on them that are not present on your machine. Compare with the .csproj files of your other projects which don't have any issues.
 
No - that's the problem, only a few are. Even if I delete and re-add one pointing to the right path, they are still broken. I checked the .csproj file before and after re-adding and the hint path is definitely changing, but I still have the yellow warnings on them
 
Do a full clean build of that MVC project and look at all the errors and warnings in the build output pane. It should give you more details than just "This project references NuGet package(s) that are missing on this computer. Use NuGet Package Restore to download them."
 
Same error and only one error appears:

Severity Code Description Project File Line Suppression State
Error This project references NuGet package(s) that are missing on this computer. Use NuGet Package Restore to download them. For more information, see Troubleshooting NuGet Package Restore in Visual Studio. The missing file is ..\packages\Microsoft.CodeDom.Providers.DotNetCompilerPlatform.2.0.0\build\net46\Microsoft.CodeDom.Providers.DotNetCompilerPlatform.props. ...

I tried "Nuget Package Restore" on the solution level and that didn't work. Also tried Upgrading the current package. The path inside the .csproj file definitely points to the correct package directory and the package is there. I also updated Visual Studio 2017.
 
Notice that you upgraded to .NET Framework 4.7, but that error there is trying to read .NET 4.6:

..\packages\Microsoft.CodeDom.Providers.DotNetCompilerPlatform.2.0.0\build\net46\Microsoft.CodeDom.Providers.DotNetCompilerPlatform.props

Furthermore, you said you upgraded all the Nuget packages. I believe Roslyn is up to 3.6, but that refers to 2.0.
 
Ok so I followed this instruction and it worked. Whatever this element is in the .csproj file, it was breaking everything:



csproj bit:
<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>

Commenting this out fixed it.
 
The error condition is fired if it cant file the file "NuGet.targets" in the ".nuget" directory right below your solution directory. I'm guessing that the older versions of Nuget creates that file in that directory, but the newer version doesn't anymore, but the build rules still expect to find it.
 

Latest posts

Back
Top Bottom