How do I fix missing NuGet references? - visual-studio

I'm using Visual Studio Professional 2017, version 15.6.6. A co-worker gave me a solution which he says I should be able to open and rebuild without any problems. There seems to be something wrong with either the NuGet packages and/or Framework. Co-worker will only say it must be something wrong with my computer, so I'm hoping someone here can help.
I tried right clicking on the solution and picking "Restore NuGet Packages". The references still have the yellow triangle by them. I tried to rebuild anyway and got the message "The reference assembilies for framework ".NETFramework, Version=v6.0" were not found. I looked at the project properties and saw the target framework was blank. I tried choosing .NET Framework 4.6, but that gave me multiple errors of the type "Package [name of NuGet package] is not compatible with net46(.NETFramework, Version=v4.6)." The co-worker had mentioned trying .NET Core before, so I tried downloading .NET Core 3.1 from this site: https://dotnet.microsoft.com/en-us/download/visual-studio-sdks?cid=getdotnetsdk. I installed it (including restarting my computer), but don't see .NET Core in the Target framework. Can anyone help guide me getting this solution running?
Here's an image showing the missing references (yellow triangle) on the right and the reference error message when I tried to rebuild.
Here's an image after I set the framework to 4.6 and showing the target framework choices I have available:

We can see that:
.NET 6 is supported by Visual Studio 2022 and Visual Studio 2022 for Mac (and later versions).
You can update to VS2022 and try again.

Related

Build Definition Not Building After Nuget package Update In Visual Studio

I inherited a lot of stuff that is above my knowledge level, but I am the only one here that is close enough to that level to figure it out. I feel like I learn quickly, and I have been able to jump every hurdle so far without too much time taken, but I just can't figure this out!
Basically we use TFS 2015 and in that we have a build definition that goes through an agent on a remote computer (that I can remote into).So, one of the developers checked in code with an updated NuGet package (Newtonsoft.Json) and it broke the build. The files and everything build locally just fine, but the build bot is broken.
I have a screenshot on imgur for a little context in my build definition and the webhook we use to send the notification in slack links to a an error page that tells me "error: Build Not Found" so I am all kinds of confused and I can't find anything online that can help me.
EDIT:
In my build logs I got this error
Error CS0246: The type or namespace name 'DataSourceRequest' could not be found (are you missing a using directive or an assembly reference?)
All of my other branch builds work and the only difference is that I updated the nuget package. Is there any way for me to upgrade the nuget package in the build agent?
Screenshot of Build Definition:
Build Definition Not Building After Nuget package Update In Visual Studio
AFAIK, the reason of this issue may be that you upgraded the package Newtonsoft.Json to version 9.01 or higher.
Starting from Newtonsoft.Json 9.0.1, this package supports the targets framework .NETStandard:
https://www.nuget.org/packages/Newtonsoft.Json/9.0.1:
Which is supported by NuGet 2.12 for Visual Studio 2013:
NuGet 2.12 Release Notes
Full NetStandard and NetCoreApp support for VS2013.
So, to resolve this issue, you should make sure the nuget.exe version is higher than 2.12 and the Visual Studio version is high than 2013.
Besides, as we know, Visual Studio are backwards compatible. Meaning we could use the lower version Visual Studio to develop the project and we could build it with a higher version of Visual Studio on the agent. But if the other way around, develop it with higher version, build it with lower version on the agent, we may encounter some issues due to compatibility. So, If we keep that the Visual Studio version on the agent is higher than the version you are developing, it would be better.
Hope this helps.

cannot build in release only in debug

I have a project built in VS 2013, for some reason I cannot build in release mode only debug mode. If I build in release mode I get a bunch of errors that doesn't really seem relavant. Anyone got any suggestion on where to begin looking for errors?
From your error I can guess that you're using an external library, either through NuGet or locally.
You have to set up the environment to use this library in both release and debug mode. That means installing it on either one through NuGet or setting up the correct include/library paths in the project settings.
In my case it was an unrelated Nuget package that had a higher .Net Framework version than my project.
I had a similar problem, with the same error of Invalid pointer, and it turned out that I had uninstalled Telerik from machine.
1. Make sure that you have Telerik installed , on my machine it is under "C:\Program Files (x86)\Telerik\UI for ASP.NET AJAX Q3 2015\"
The file "Telerik.Web.UI.dll" is available in the Bin[nn]-folders, select the one you want (perhaps the latest version).
2. In visual studio; if your reference to "Telerik.Web.UI" has a yellow warning triangle it indicates that Visual Studio cannot locate the dll file.
Add new reference by browsing your Telerik Bin[nn] folder and selecting the file "Telerik.Web.UI.dll" (and repeat this for all projects using the Telerik components in your solution)

Entity Framework Build Issue in VS 2012 .NET 4.5

Is there any trick/workaround/known "gotcha" regarding Entity Framework 4 and Visual Studio 2012?
I have a project that works and compiles perfectly on my Windows 7, VS 2010, .NET 4 box. Over the weekend I setup a new machine, with Windows 8 Enterprise RTM, and VS 2012 Ultimate RTM. EF design is out of the box, using ObjectContext approach (pre EF 4.1).
I retrieved the working solution from source control, went through conversion process, and get it to build successfully in VS2012 targeting the .NET 4 Framework.
However, when I run the app or debug it, I get "unable to load metadata resource" from the first EF call. Soo ..
Step 1: Work the EF error
Ok, so I use dotPeek to see the assembly, and sure enough when built in VS2012, the EDMX metadata files are not in the assembly.
Step 2: work the missing resources problem
I set metadata processing to "copy to output" and then back to "embed" to force. Nope.
I looked around the MSBUILD files for 4.5 to see if the EntityDeploy targets looked corrupt. Nope.
I did a full repair on VS 2012 to see if something got messed up. Nope.
Set MSBUILD VS version to "11.0" to avoid the 2010 compatibility checks in the csproj. Nope.
Step 3: Delete model, try again using VS 2012 defaults
Ok, I figured I just couldnt make this work. So I deleted the model, and readded as new in VS 2012, which uses EF 5.0 from NuGet, and recontructs using the DbContext approach. Got all this lined up, fixed a few syntax things b/t EF 4.0 and 5.0 and we are building.
Still get same error, still no resources in .DLL
A collegue of mine can build this successful in VS 2012 but on Windows 7 w/o .NET 4.5 installed.
Is there a bug or known issue in .NET 4.5 or MSBUILD 4.5? gotta be missing someting simple.
Figured it out. I don't have a .resources file in this project and it appears CoreCompile in .NET 4.5 is not embedding any of the EF resources files without that being present.
Trying to research is this is expected or new behavior.

Target Framework does not change in Visual Studio 2010

When I change the target framework of any project in Visual Studio 2010 it does not actually change the System assembly references. For example if I target v2.0 and check the properties of System and System.Data I can see that they are still both v4.0. If i change the target to v3.5, System stays at v4.0 but System.Core changes to v3.5.
Because of this I am truly not targeting anything except v4.0.
There may be something strange in your install. I just created a WPF project, keeping the default settings, thus targeting .NET 4. Then, I switched to 3.5. VS asked to reload the project and then the targeted runtime of the references was v2 (correct) and their version was 3.5 (with an error that Microsoft.CSharp and System.Xaml were missing, which is understandable).
Then, I did the same for .NET 3 and 2 and got the same results: after reloading the project, the version of the referenced DLLs had changed were it made sense (System.Data is always v2.0).
When using the CLR v2, the vshost debug helper had its name changed to something like vshost-clrv2.
I've reinstalled Visual Studio several times and it hasn't solved anything. After uninstalling there is 10.0 stuff laying all over the place leading me to believe the uninstaller is also leaving what ever is causing this issue. I'm going to have to reinstall the OS to get the issue to go away.
I also wanted to link to my earlier post because this post has more information about how I originally discovered this issue, contains a link to the Microsoft Connect bug report I opened and links to several other users experiencing the same problem: Visual Studio 2010 Can no longer build .NET v3.5

Visual Studio 2005 Can't find System assemblies

I have Visual Studio 2008 installed on my machine, but I haven't used it. I did open a dummy project and make sure that version 2.0 is the .NET Framework version I am using, since it is the one that suddenly doesn't work for me.
Here's the warning message I get when I am trying to open an existing Windows 2005 project.
"Namespace or type specified in the project level Imports 'System.Data' doesn't contain any public member or cannot be found."
All of the basic System, System.Data, System.XML assemblies show up in a new project with the yellow exclamation point warning.
Does anyone know how I can solve this issue? Please help!
I would start by downloading and re-installing .NET 2.0 on your system.
You could check the project references and make sure that you have System.Data added to the project.

Resources