All MS VS References broken after project moved - windows

Exactly as asked in Moved project, now references are broken -- having moved a project to another folder, now all of my references are broken, however, the answer there is incorrect, as we can see that it is not only the NuGet Packages are broken, but all of them, even including System, Microsoft.CSharp, etc:
How to properly fix it?
This is
Microsoft Visual Studio Enterprise 2017
Version 15.3.5
VisualStudio.15.Release/15.3.5+26730.16
Microsoft .NET Framework
Version 4.6.01038
UPDATE:
Find a case that is even don't need moving anything -- I tried to include a project from another solution, whose references are perfectly fine within that solution, but all are broken when included in my new solution, despite the fact that all the references, accessible (specified in the .csproj file) via relative paths or no path at all:
<Reference Include="System" />
<Reference Include="System.Core" />
<Reference Include="System.Drawing" />
<Reference Include="System.Management" />
<Reference Include="System.Web.Extensions" />
<Reference Include="System.Windows.Forms" />
<Reference Include="System.Xml.Linq" />
<Reference Include="System.Data.DataSetExtensions" />
<Reference Include="Microsoft.CSharp" />
<Reference Include="System.Data" />
<Reference Include="System.Xml" />
<Reference Include="WebDriver, Version=3.4.0.0, Culture=neutral, processorArchitecture=MSIL">
<HintPath>..\..\..\..\packages\Selenium.WebDriver.3.4.0\lib\net40\WebDriver.dll</HintPath>
<Private>True</Private>
</Reference>
<Reference Include="WebDriver.Support, Version=3.4.0.0, Culture=neutral, processorArchitecture=MSIL">
<HintPath>..\..\..\..\packages\Selenium.Support.3.4.0\lib\net40\WebDriver.Support.dll</HintPath>
<Private>True</Private>
</Reference>

Related

VS2017 vstemplate automatically install Nuget Package?

Hi I have a Nuget Package and want to let it automatically install after project is created.
I added this into my vstemplate file:
<WizardExtension>
<Assembly>NuGet.VisualStudio.Interop, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null</Assembly>
<FullClassName>NuGet.VisualStudio.TemplateWizard</FullClassName>
</WizardExtension>
<WizardData>
<packages>
<package id="MyWebVisuDlls" version="1.0.5" />
</packages>
</WizardData>
It works it adds the Nuget to the Project after I created a new one from template, BUT it does not install the dlls from the Nuget Package. It just gives me a warning that there are unupdated/installed Nuget Packages in the project. And if I click on Update Now the Dlls are getting installed.
Is there a way to do this automatically? I litterly searched a whole day now and besides an own VSIX Project I cant find anything.
Is there a way to do this automatically? I litterly searched a whole
day now and besides an own VSIX Project I cant find anything.
l am sure that it can be realized. You can just modify your projecttemplate.csproj file and then add the Reference code to these packages. And you need to be clear that when you create a project based on your new template, VS will automatically read xxx.csproj and then recover the corresponding nuget package based on the information in it.
Besides, it is important to note that nuget packages can be referenced in two ways, packages.config and PackageReference.(It really depends on which way you want to import the package).
Solution
1) use PackageReference
a) modify ProjectTemplate.csproj(which is in the Solution Explorer just like the picture below) and then add this:
<ItemGroup>
<PackageReference Include="MyWebVisuDlls">
<Version>1.0.5</Version>
</PackageReference>
</ItemGroup>
b) publish this template and then you can use it.
2) use Packages.config
a) Create a file called packages.config in your project root directory and then add these in it
<?xml version="1.0" encoding="utf-8"?>
<packages>
<package id="MyWebVisuDlls" version="1.0.5" targetFramework="net472" />
</packages>
TargetFramework mainly means your framework version of your current project. For me, l created a net framework 4.7.2 c# project template project, so I used net472.
b) right-click the file and select Property and change Build Action to Content, Copy to Output Directory to Copy always and then change Include in VSIX to True.
c) add these files in projecttemplate.csproj as above:
<ItemGroup>
<Content Include="packages.config">
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
</Content>
</ItemGroup>
<ItemGroup>
<Reference Include="Antlr3.Runtime, Version=3.5.0.2, Culture=neutral, PublicKeyToken=eb42632606e9261f, processorArchitecture=MSIL">
<HintPath>..\packages\MyWebVisuDlls.1.0.5\lib\net45\Antlr3.Runtime.dll</HintPath>
</Reference>
<Reference Include="AspNet.ScriptManager.bootstrap, Version=3.3.6.0, Culture=neutral, processorArchitecture=MSIL">
<HintPath>..\packages\MyWebVisuDlls.1.0.5\lib\net45\AspNet.ScriptManager.bootstrap.dll</HintPath>
</Reference>
<Reference Include="AspNet.ScriptManager.jQuery, Version=3.3.1.0, Culture=neutral, processorArchitecture=MSIL">
<HintPath>..\packages\MyWebVisuDlls.1.0.5\lib\net45\AspNet.ScriptManager.jQuery.dll</HintPath>
</Reference>
<Reference Include="DevExpress.Charts.v16.1.Core, Version=16.1.14.0, Culture=neutral, PublicKeyToken=b88d1754d700e49a, processorArchitecture=MSIL">
<HintPath>..\packages\MyWebVisuDlls.1.0.5\lib\net45\DevExpress.Charts.v16.1.Core.dll</HintPath>
</Reference>
<Reference Include="DevExpress.Data.v16.1, Version=16.1.14.0, Culture=neutral, PublicKeyToken=b88d1754d700e49a, processorArchitecture=MSIL">
<HintPath>..\packages\MyWebVisuDlls.1.0.5\lib\net45\DevExpress.Data.v16.1.dll</HintPath>
</Reference>
<Reference Include="DevExpress.Office.v16.1.Core, Version=16.1.14.0, Culture=neutral, PublicKeyToken=b88d1754d700e49a, processorArchitecture=MSIL">
<HintPath>..\packages\MyWebVisuDlls.1.0.5\lib\net45\DevExpress.Office.v16.1.Core.dll</HintPath>
</Reference>
<Reference Include="DevExpress.Printing.v16.1.Core, Version=16.1.14.0, Culture=neutral, PublicKeyToken=b88d1754d700e49a, processorArchitecture=MSIL">
<HintPath>..\packages\MyWebVisuDlls.1.0.5\lib\net45\DevExpress.Printing.v16.1.Core.dll</HintPath>
</Reference>
<Reference Include="DevExpress.RichEdit.v16.1.Core, Version=16.1.14.0, Culture=neutral, PublicKeyToken=b88d1754d700e49a, processorArchitecture=MSIL">
<HintPath>..\packages\MyWebVisuDlls.1.0.5\lib\net45\DevExpress.RichEdit.v16.1.Core.dll</HintPath>
</Reference>
<Reference Include="DevExpress.Utils.v16.1, Version=16.1.14.0, Culture=neutral, PublicKeyToken=b88d1754d700e49a, processorArchitecture=MSIL">
<HintPath>..\packages\MyWebVisuDlls.1.0.5\lib\net45\DevExpress.Utils.v16.1.dll</HintPath>
</Reference>
<Reference Include="DevExpress.Web.ASPxThemes.v16.1, Version=16.1.14.0, Culture=neutral, PublicKeyToken=b88d1754d700e49a, processorArchitecture=MSIL">
<HintPath>..\packages\MyWebVisuDlls.1.0.5\lib\net45\DevExpress.Web.ASPxThemes.v16.1.dll</HintPath>
</Reference>
<Reference Include="DevExpress.Web.Resources.v16.1, Version=16.1.14.0, Culture=neutral, PublicKeyToken=b88d1754d700e49a, processorArchitecture=MSIL">
<HintPath>..\packages\MyWebVisuDlls.1.0.5\lib\net45\DevExpress.Web.Resources.v16.1.dll</HintPath>
</Reference>
<Reference Include="DevExpress.Web.v16.1, Version=16.1.14.0, Culture=neutral, PublicKeyToken=b88d1754d700e49a, processorArchitecture=MSIL">
<HintPath>..\packages\MyWebVisuDlls.1.0.5\lib\net45\DevExpress.Web.v16.1.dll</HintPath>
</Reference>
<Reference Include="DevExpress.XtraCharts.v16.1, Version=16.1.14.0, Culture=neutral, PublicKeyToken=b88d1754d700e49a, processorArchitecture=MSIL">
<HintPath>..\packages\MyWebVisuDlls.1.0.5\lib\net45\DevExpress.XtraCharts.v16.1.dll</HintPath>
</Reference>
<Reference Include="DevExpress.XtraCharts.v16.1.Extensions, Version=16.1.14.0, Culture=neutral, PublicKeyToken=b88d1754d700e49a, processorArchitecture=MSIL">
<HintPath>..\packages\MyWebVisuDlls.1.0.5\lib\net45\DevExpress.XtraCharts.v16.1.Extensions.dll</HintPath>
</Reference>
<Reference Include="DevExpress.XtraCharts.v16.1.UI, Version=16.1.14.0, Culture=neutral, PublicKeyToken=b88d1754d700e49a, processorArchitecture=MSIL">
<HintPath>..\packages\MyWebVisuDlls.1.0.5\lib\net45\DevExpress.XtraCharts.v16.1.UI.dll</HintPath>
</Reference>
<Reference Include="DevExpress.XtraCharts.v16.1.Web, Version=16.1.14.0, Culture=neutral, PublicKeyToken=b88d1754d700e49a, processorArchitecture=MSIL">
<HintPath>..\packages\MyWebVisuDlls.1.0.5\lib\net45\DevExpress.XtraCharts.v16.1.Web.dll</HintPath>
</Reference>
<Reference Include="DevExpress.XtraCharts.v16.1.Wizard, Version=16.1.14.0, Culture=neutral, PublicKeyToken=b88d1754d700e49a, processorArchitecture=MSIL">
<HintPath>..\packages\MyWebVisuDlls.1.0.5\lib\net45\DevExpress.XtraCharts.v16.1.Wizard.dll</HintPath>
</Reference>
<Reference Include="getBeckhoffTpy, Version=4.3.1.0, Culture=neutral, PublicKeyToken=4481a3cada349683, processorArchitecture=MSIL">
<HintPath>..\packages\MyWebVisuDlls.1.0.5\lib\net45\getBeckhoffTpy.dll</HintPath>
</Reference>
<Reference Include="Microsoft.AspNet.FriendlyUrls, Version=1.0.2.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35, processorArchitecture=MSIL">
<HintPath>..\packages\MyWebVisuDlls.1.0.5\lib\net45\Microsoft.AspNet.FriendlyUrls.dll</HintPath>
</Reference>
<Reference Include="Microsoft.AspNet.Web.Optimization.WebForms, Version=1.1.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35, processorArchitecture=MSIL">
<HintPath>..\packages\MyWebVisuDlls.1.0.5\lib\net45\Microsoft.AspNet.Web.Optimization.WebForms.dll</HintPath>
</Reference>
<Reference Include="Microsoft.CodeDom.Providers.DotNetCompilerPlatform, Version=2.0.1.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35, processorArchitecture=MSIL">
<HintPath>..\packages\MyWebVisuDlls.1.0.5\lib\net45\Microsoft.CodeDom.Providers.DotNetCompilerPlatform.dll</HintPath>
</Reference>
<Reference Include="Microsoft.CSharp, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a, processorArchitecture=MSIL">
<HintPath>..\packages\MyWebVisuDlls.1.0.5\lib\net45\Microsoft.CSharp.dll</HintPath>
</Reference>
<Reference Include="Microsoft.ScriptManager.MSAjax, Version=5.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35, processorArchitecture=MSIL">
<HintPath>..\packages\MyWebVisuDlls.1.0.5\lib\net45\Microsoft.ScriptManager.MSAjax.dll</HintPath>
</Reference>
<Reference Include="Microsoft.ScriptManager.WebForms, Version=5.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35, processorArchitecture=MSIL">
<HintPath>..\packages\MyWebVisuDlls.1.0.5\lib\net45\Microsoft.ScriptManager.WebForms.dll</HintPath>
</Reference>
<Reference Include="Microsoft.Web.Infrastructure, Version=1.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35, processorArchitecture=MSIL">
<HintPath>..\packages\MyWebVisuDlls.1.0.5\lib\net45\Microsoft.Web.Infrastructure.dll</HintPath>
</Reference>
<Reference Include="Newtonsoft.Json, Version=11.0.0.0, Culture=neutral, PublicKeyToken=30ad4fe6b2a6aeed, processorArchitecture=MSIL">
<HintPath>..\packages\MyWebVisuDlls.1.0.5\lib\net45\Newtonsoft.Json.dll</HintPath>
</Reference>
<Reference Include="Npgsql, Version=3.2.6.0, Culture=neutral, PublicKeyToken=5d8b90d52f46fda7, processorArchitecture=MSIL">
<HintPath>..\packages\MyWebVisuDlls.1.0.5\lib\net45\Npgsql.dll</HintPath>
</Reference>
<Reference Include="System.Web.Optimization, Version=1.1.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35, processorArchitecture=MSIL">
<HintPath>..\packages\MyWebVisuDlls.1.0.5\lib\net45\System.Web.Optimization.dll</HintPath>
</Reference>
<Reference Include="TwinCAT.Ads, Version=4.2.163.0, Culture=neutral, PublicKeyToken=180016cd49e5e8c3, processorArchitecture=MSIL">
<HintPath>..\packages\MyWebVisuDlls.1.0.5\lib\net45\TwinCAT.Ads.dll</HintPath>
</Reference>
<Reference Include="WebGrease, Version=1.6.5135.21930, Culture=neutral, PublicKeyToken=31bf3856ad364e35, processorArchitecture=MSIL">
<HintPath>..\packages\MyWebVisuDlls.1.0.5\lib\net45\WebGrease.dll</HintPath>
</Reference>
</ItemGroup>
Usually, MyWebVisuDlls package has many dependencies. And using packages.config needs to list them which may be a little trouble.
In short, I recommend the first way to use PackageReference which is a easy way to realize it.
Hope it could help you.

Visual studio 2015 project missing all references

Starting from today, a WPF project that belongs to a solution with 20 projects, set all my references to missing
I've just checked the MS suggestion and the other answers on Stackoverflow but none worked...I've tried to re-get solution from SVN, with no luck, other colleagues haven't got this problem.
I've also tried to remove and re-add the references (System.Xml for example) .
But no way to make it work...
Any suggestion?
Thanks
UPDATE #1
Here's the csproj
<ItemGroup>
<Reference Include="Catel.Core, Version=4.2.0.0, Culture=neutral, processorArchitecture=MSIL">
<HintPath>..\packages\Catel.Core.4.2.0\lib\net40\Catel.Core.dll</HintPath>
<Private>True</Private>
</Reference>
<Reference Include="Catel.Extensions.Controls, Version=4.2.0.0, Culture=neutral, processorArchitecture=MSIL">
<HintPath>..\packages\Catel.Extensions.Controls.4.2.0\lib\net40\Catel.Extensions.Controls.dll</HintPath>
<Private>True</Private>
</Reference>
<Reference Include="Catel.Extensions.FluentValidation, Version=4.2.0.0, Culture=neutral, processorArchitecture=MSIL">
<HintPath>..\packages\Catel.Extensions.FluentValidation.4.2.0\lib\net40\Catel.Extensions.FluentValidation.dll</HintPath>
<Private>True</Private>
</Reference>
<Reference Include="Catel.Fody.Attributes, Version=2.8.0.0, Culture=neutral, PublicKeyToken=1c8163524cbe02e6, processorArchitecture=MSIL">
<HintPath>..\packages\Catel.Fody.2.8.0\lib\portable-net4+sl4+wp7+win8+wpa81+MonoAndroid14+MonoTouch40\Catel.Fody.Attributes.dll</HintPath>
<Private>True</Private>
</Reference>
<Reference Include="Catel.MVVM, Version=4.2.0.0, Culture=neutral, processorArchitecture=MSIL">
<HintPath>..\packages\Catel.MVVM.4.2.0\lib\net40\Catel.MVVM.dll</HintPath>
<Private>True</Private>
</Reference>
<Reference Include="MethodTimer, Version=1.15.7.0, Culture=neutral, PublicKeyToken=cb1364609f40a1dc, processorArchitecture=MSIL">
<HintPath>..\packages\MethodTimer.Fody.1.15.7.0\Lib\portable-net4+sl5+wp8+win8+wpa81+MonoAndroid16+MonoTouch40\MethodTimer.dll</HintPath>
<Private>False</Private>
</Reference>
<Reference Include="Microsoft.Threading.Tasks, Version=1.0.12.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a, processorArchitecture=MSIL">
<HintPath>..\packages\Microsoft.Bcl.Async.1.0.168\lib\net40\Microsoft.Threading.Tasks.dll</HintPath>
<Private>True</Private>
</Reference>
<Reference Include="Microsoft.Threading.Tasks.Extensions, Version=1.0.12.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a, processorArchitecture=MSIL">
<HintPath>..\packages\Microsoft.Bcl.Async.1.0.168\lib\net40\Microsoft.Threading.Tasks.Extensions.dll</HintPath>
<Private>True</Private>
</Reference>
<Reference Include="Microsoft.Threading.Tasks.Extensions.Desktop, Version=1.0.168.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a, processorArchitecture=MSIL">
<HintPath>..\packages\Microsoft.Bcl.Async.1.0.168\lib\net40\Microsoft.Threading.Tasks.Extensions.Desktop.dll</HintPath>
<Private>True</Private>
</Reference>
<Reference Include="PresentationCore" />
<Reference Include="PresentationFramework" />
<Reference Include="ServiceStack">
<HintPath>..\packages\ServiceStack.4.0.46\lib\net40\ServiceStack.dll</HintPath>
<Private>True</Private>
</Reference>
<Reference Include="ServiceStack.Client, Version=4.0.46.0, Culture=neutral, processorArchitecture=MSIL">
<HintPath>..\packages\ServiceStack.Client.4.0.46\lib\net40\ServiceStack.Client.dll</HintPath>
<Private>True</Private>
</Reference>
<Reference Include="ServiceStack.Common">
<HintPath>..\packages\ServiceStack.Common.4.0.46\lib\net40\ServiceStack.Common.dll</HintPath>
<Private>True</Private>
</Reference>
<Reference Include="ServiceStack.Interfaces, Version=4.0.0.0, Culture=neutral, PublicKeyToken=e06fbc6124f57c43, processorArchitecture=MSIL">
<HintPath>..\packages\ServiceStack.Interfaces.4.0.46\lib\portable-wp80+sl5+net40+win8+monotouch+monoandroid+xamarin.ios10\ServiceStack.Interfaces.dll</HintPath>
<Private>True</Private>
</Reference>
<Reference Include="ServiceStack.Text, Version=4.0.46.0, Culture=neutral, processorArchitecture=MSIL">
<HintPath>..\packages\ServiceStack.Text.4.0.46\lib\net40\ServiceStack.Text.dll</HintPath>
<Private>True</Private>
</Reference>
<Reference Include="System" />
<Reference Include="System.ComponentModel.DataAnnotations" />
<Reference Include="System.Configuration" />
<Reference Include="System.Core" />
<Reference Include="System.IO, Version=2.6.10.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a, processorArchitecture=MSIL">
<HintPath>..\packages\Microsoft.Bcl.1.1.10\lib\net40\System.IO.dll</HintPath>
<Private>True</Private>
</Reference>
<Reference Include="System.Management" />
<Reference Include="System.Net" />
<Reference Include="System.Runtime, Version=2.6.10.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a, processorArchitecture=MSIL">
<HintPath>..\packages\Microsoft.Bcl.1.1.10\lib\net40\System.Runtime.dll</HintPath>
<Private>True</Private>
</Reference>
<Reference Include="System.Threading.Tasks, Version=2.6.10.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a, processorArchitecture=MSIL">
<HintPath>..\packages\Microsoft.Bcl.1.1.10\lib\net40\System.Threading.Tasks.dll</HintPath>
<Private>True</Private>
</Reference>
<Reference Include="System.Windows.Interactivity, Version=4.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35, processorArchitecture=MSIL">
<HintPath>..\packages\Catel.MVVM.4.2.0\lib\net40\System.Windows.Interactivity.dll</HintPath>
<Private>True</Private>
</Reference>
<Reference Include="System.Xaml" />
<Reference Include="System.Xml.Linq" />
<Reference Include="System.Data.DataSetExtensions" />
<Reference Include="Microsoft.CSharp" />
<Reference Include="System.Data" />
<Reference Include="System.Net.Http" />
<Reference Include="System.Xml" />
<Reference Include="Telerik.Windows.Controls, Version=2015.2.728.40, Culture=neutral, PublicKeyToken=5803cfa389c90ce7, processorArchitecture=MSIL">
<HintPath>..\packages\Telerik.Windows.Controls.for.Wpf.40.Xaml.2015.2.728\lib\net40\Telerik.Windows.Controls.dll</HintPath>
<Private>True</Private>
</Reference>
<Reference Include="Telerik.Windows.Controls.GridView, Version=2015.2.728.40, Culture=neutral, PublicKeyToken=5803cfa389c90ce7, processorArchitecture=MSIL">
<HintPath>..\packages\Telerik.Windows.Controls.GridView.for.Wpf.40.Xaml.2015.2.728\lib\net40\Telerik.Windows.Controls.GridView.dll</HintPath>
<Private>True</Private>
</Reference>
<Reference Include="Telerik.Windows.Controls.Input, Version=2015.2.728.40, Culture=neutral, PublicKeyToken=5803cfa389c90ce7, processorArchitecture=MSIL">
<HintPath>..\packages\Telerik.Windows.Controls.Input.for.Wpf.40.Xaml.2015.2.728\lib\net40\Telerik.Windows.Controls.Input.dll</HintPath>
<Private>True</Private>
</Reference>
<Reference Include="Telerik.Windows.Controls.Navigation, Version=2015.2.728.40, Culture=neutral, PublicKeyToken=5803cfa389c90ce7, processorArchitecture=MSIL">
<HintPath>..\packages\Telerik.Windows.Controls.Navigation.for.Wpf.40.Xaml.2015.2.728\lib\net40\Telerik.Windows.Controls.Navigation.dll</HintPath>
<Private>True</Private>
</Reference>
<Reference Include="Telerik.Windows.Data, Version=2015.2.728.40, Culture=neutral, PublicKeyToken=5803cfa389c90ce7, processorArchitecture=MSIL">
<HintPath>..\packages\Telerik.Windows.Data.for.Wpf.40.Xaml.2015.2.728\lib\net40\Telerik.Windows.Data.dll</HintPath>
<Private>True</Private>
</Reference>
<Reference Include="UIAutomationProvider" />
<Reference Include="UIAutomationTypes" />
<Reference Include="WindowsBase" />
Yes I use Nuget, the other 19 points to the same assemblies ...nothing has been moved
UPDATE #2
Since I was not able to proceed I've copied the project from a colleague and now it works.... think something went wrong in the filesystem...have compared the solution and they were identical
The resolution to this issue is.
Whenever you import a project to VS 2015 it modifies your .csproj. So, in order to fix it. Right click on .csproj and open it in notepad or any editor and delete the following
<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>
Then build your solution and it should work.
In the root directory of the solution, delete everything inside of /packages/ folder, then do a re-build.
It can help to force rebuild the nuget packages. Go to the nuget console and use the following commands: (TOOLS > Options > Package Manager > Package Manager Conbsole)
Update-Package -reinstall -ProjectName "MyProject" -safe
The safe parameter will actually not update the packages, but only reinstall them. If that didn't help, you can try to actually update them (but make sure you have a copy of the project somewhere, just in case.)
Update-Package -reinstall -ProjectName "MyProject"
To force update just one package, use:
Update-Package -id Microsoft.Package.Name -ProjectName "MyProject"
I had this once, caused by a broken .targets import. Check if you accidentally enabled nuget package restore (which includes a .targets file) and then deleted the .nuget directory.
I had similar issue. The solution, which worked for me was to pop the nuget package manager for the solution and refresh the packages.
Another case involved missing packages and nuget package manager for the solution showed updates and dependencies, which needed to be installed and this was the fix.
Another case was exactly as pointed above - delete packages folder fixed it.
Editing manually the project is an option, but there is a chance if you poke where you are not supposed to, your project may not open. If you can, avoid doing that is my opinion.
I've just experienced exactly this in VS2015 on a solution with around 20 projects. Only one project was affected and it lost all references including to the standard .NET assemblies.
The only way I could resolve was to switch to a different GIT branch and then back, this cleaned up the issue and it is all now working.
I also experienced exactly this in VS2015 on a solution with around 10 projects. Only one project - the main MVC project - was affected and it lost all references including to the standard .NET assemblies.
The problem was in my web.config. I had commented some lines, resulting in an invalid xml-file.
This error may occur if you miss .targets file in nuget packages folder. In my case it was
packages\Microsoft.Bcl.Build.1.0.21\build\Microsoft.Bcl.Build.targets
Usually it happens when I'm adding packages to git repository (common .gitignore file is ignoring build folder everywhere) and checkout on another computer.
Tip: you can modify .gitignore file to include all files in packages folder. Append these lines to the bottom:
# Include all files in NuGet packages directory
!/packages/**/
For me I had mistakenly removed the following line from .csproj file:
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
So I closed Visual Studio. Opened myprojectname.csproj file and added the line.
then I reopened the solution and by that I was able to resolve my issue.
Unload project, then edit project
look for the following and delete.
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}.

Opening an MVC3 project on a machine without MVC3 installed?

I've read the blog posts on deploying MVC3 projects to shared hosting environments that do not have MVC3 installed:
http://www.iwantmymvc.com/2011-03-23-bin-deploy-aspnet-mvc-3-visual-studio
I'm opening an MVC3 project in VS2010 on a machine that does not have MVC3 installed. I have added the references to my *.csproj file:
<Reference Include="System.Web.Mvc, Version=3.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35, processorArchitecture=MSIL">
<HintPath>..\..\lib\System.Web.Mvc.dll</HintPath>
</Reference>
<Reference Include="System.Web.Helpers">
<HintPath>..\..\lib\System.Web.Helpers.dll</HintPath>
</Reference>
<Reference Include="System.Web.Razor">
<HintPath>..\..\lib\System.Web.Razor.dll</HintPath>
</Reference>
<Reference Include="System.Web.WebPages">
<HintPath>..\..\lib\System.Web.WebPages.dll</HintPath>
</Reference>
<Reference Include="System.Web.WebPages.Deployment">
<HintPath>..\..\lib\System.Web.WebPages.Deployment.dll</HintPath>
</Reference>
<Reference Include="System.Web.WebPages.Razor">
<HintPath>..\..\lib\System.Web.WebPages.Razor.dll</HintPath>
</Reference>
<Reference Include="Microsoft.Web.Infrastructure">
<HintPath>..\..\lib\Microsoft.Web.Infrastructure.dll</HintPath>
</Reference>
I'm still getting the following error:
The project type is not supported by this installation.
I'll open up the project on a machine with MVC3 installed and browse to the references, which correctly points to the local lib file. What am I missing?
Please take a look at this blog post http://weblogs.asp.net/leftslipper/archive/2009/01/20/opening-an-asp-net-mvc-project-without-having-asp-net-mvc-installed-the-project-type-is-not-supported-by-this-installation.aspx

xaml assembly reference problem

I have a problem where most of the assemblies I'm referencing in my silverlight application appear to be not found in the xaml, despite the fact that I've added the references to the project using the 'Add Reference' dialog, can see they are present in the specified location, and can browse them using the object browser.
I'm using VS 2010 and SL4,
and the latest SL toolkit
Here are the references in the fsproj file...
<ItemGroup>
<Reference Include="FSharp.PowerPack">
<HintPath>C:\Program Files\FSharpPowerPack-2.0.0.0\Silverlight\v3.0\FSharp.PowerPack.dll</HintPath>
</Reference>
<Reference Include="mscorlib" />
<Reference Include="FSharp.Core">
<HintPath>$(ProgramFiles)\Microsoft F#\Silverlight\Libraries\Client\$(SilverlightVersion)\FSharp.Core.dll</HintPath>
</Reference>
<Reference Include="System" />
<Reference Include="System.ComponentModel.DataAnnotations" />
<Reference Include="System.Core" />
<Reference Include="System.Net" />
<Reference Include="System.Runtime.Serialization" />
<Reference Include="System.Windows" />
<Reference Include="System.Windows.Browser" />
<Reference Include="System.Windows.Controls">
<HintPath>bin\Debug\System.Windows.Controls.dll</HintPath>
</Reference>
<Reference Include="System.Windows.Controls.Data">
<HintPath>bin\Debug\System.Windows.Controls.Data.dll</HintPath>
</Reference>
<Reference Include="System.Windows.Controls.Data.Input" />
<Reference Include="System.Windows.Controls.DataVisualization.Toolkit">
<HintPath>bin\Debug\System.Windows.Controls.DataVisualization.Toolkit.dll</HintPath>
</Reference>
<Reference Include="System.Windows.Controls.Input">
<HintPath>c:\Program Files\Microsoft SDKs\Silverlight\v4.0\Libraries\Client\System.Windows.Controls.Input.dll</HintPath>
</Reference>
<Reference Include="System.Windows.Controls.Layout.Toolkit">
<HintPath>bin\Debug\System.Windows.Controls.Layout.Toolkit.dll</HintPath>
</Reference>
<Reference Include="System.Windows.Controls.Navigation">
<HintPath>c:\Program Files\Microsoft SDKs\Silverlight\v4.0\Libraries\Client\System.Windows.Controls.Navigation.dll</HintPath>
</Reference>
<Reference Include="System.Windows.Controls.Toolkit">
<HintPath>bin\Debug\System.Windows.Controls.Toolkit.dll</HintPath>
</Reference>
<Reference Include="System.Windows.Data">
<HintPath>bin\Debug\System.Windows.Data.dll</HintPath>
</Reference>
<Reference Include="System.Xml" />
</ItemGroup>
Some of them have the local path to the assembly that has been copied to the Debug dir. They are definitely there, along with the .xml files with the same name (ie; System.Windows.Controls.Navigation.dll and System.Windows.Controls.Navigation.xml). I get the same problem regardless of where they are being referenced.
Here is how they are referenced in the xaml...
<nav:Page x:Class="Module1.MyIdeas" x:Name="MyIdeas"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:data="clr-namespace:System.Windows.Controls;assembly=System.Windows.Controls.Data"
xmlns:controls="clr-namespace:System.Windows.Controls;assembly=System.Windows.Controls"
xmlns:toolkit="clr-namespace:System.Windows.Controls;assembly=System.Windows.Controls.Toolkit"
xmlns:nav="clr-namespace:System.Windows.Controls;assembly=System.Windows.Controls.Navigation"
xmlns:winControls="clr-namespace:System.Windows.Controls;assembly=System.Windows.Controls"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:y="clr-namespace:Module1" NavigationCacheMode="Enabled" >
<some content.../>
</nav:Page>
All the following assemblies have the error: "Error 1 Assembly 'System.Windows.Controls.X' was not found. Verify that you are not missing an assembly reference. Also, verify that your project and all referenced assemblies have been built."
xmlns:data="clr-namespace:System.Windows.Controls;assembly=System.Windows.Controls.Data"
xmlns:controls="clr-namespace:System.Windows.Controls;assembly=System.Windows.Controls"
xmlns:toolkit="clr-namespace:System.Windows.Controls;assembly=System.Windows.Controls.Toolkit"
xmlns:nav="clr-namespace:System.Windows.Controls;assembly=System.Windows.Controls.Navigation"
The thing is that the project builds and runs fine, but this behavior appears to break the xaml designer and intellisense.
My comment above abount creating a new project and reloading the original project seems to work fine.

What could be causing "Path Too Long" exception?

I'm trying to build a Visual Studio add-in.
For long-winded reasons (to do with using disassembled assemblies courtesy of .NET Reflector) I removed the reference to the EnvDTE assembly, then re-added it. My project still builds without any problems but when I run my project I get the following exception.
System.IO.PathTooLongException occurred
Message=The specified path, file name, or both are too long. The fully qualified file name must be less than 260 characters, and the directory name must be less than 248 characters.
Source=mscorlib
StackTrace:
at System.IO.PathHelper.GetFullPathName()
InnerException:
None of my references have particularly long paths - they're all the GAC and roughly the same length. I'm not trying to do anything different from before I had trouble with the EnvDTE assembly.
Does anyone have any ideas what might be causing this and how it can be resolved?
UPDATE:
My csproj file shows the following reference paths:
<ItemGroup>
<Reference Include="BoneSoft.CSS">
<HintPath>bin\BoneSoft.CSS.dll</HintPath>
</Reference>
<Reference Include="EnvDTE, Version=8.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a">
<EmbedInteropTypes>True</EmbedInteropTypes>
</Reference>
<Reference Include="Extensibility, Version=7.0.3300.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a">
<EmbedInteropTypes>False</EmbedInteropTypes>
</Reference>
<Reference Include="HtmlAgilityPack">
<HintPath>bin\HtmlAgilityPack.dll</HintPath>
</Reference>
<Reference Include="Microsoft.VisualStudio.OLE.Interop, Version=7.1.40304.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a" />
<Reference Include="Microsoft.VisualStudio.Shell, Version=10.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a, processorArchitecture=MSIL" />
<Reference Include="Microsoft.VisualStudio.Shell.Interop, Version=7.1.40304.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a" />
<Reference Include="microsoft.visualstudio.shell.interop.8.0, Version=8.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a" />
<Reference Include="Microsoft.VisualStudio.Shell.Interop.9.0, Version=9.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a" />
<Reference Include="System" />
<Reference Include="System.Core" />
<Reference Include="System.Data" />
<Reference Include="System.Windows.Forms" />
<Reference Include="System.Xml" />
<Reference Include="Microsoft.CSharp" />
</ItemGroup>
Try opening up your .csproj in notepad and look at the Reference entries for all of your assemblies. What's almost certainly happened is they got added with a weird relative path that caused it to extend past the 260 character limit in the HintPath node.
To fix just delete the HintPath element, reload your project and the issue should go away. It isn't necessary for EnvDTE.
I had this problem too after updating references to Telerik assemblies in my Silverlight 5 project. After deleting the HintPath nodes as JaredPar suggested, my issue was resolved. I'm providing a screen shot here to show the broken version (on left) and the fixed version (on right). Thanks JaredPar... sorry I can't vote your answer up yet.

Resources