I have a solution with a project that i developed using Visual Studio 2013 and it was working as intended. I then formatted my computer to upgrade to Windows 10 and decided to install Visual Studio 2015 instead and now I'm getting a lot of missing reference errors when they are installed, does anyone know why this is happening and how to fix it?
Some of the errors:
A good example is that I have Microsoft.Net.Http package installed but it's not recognizing it where I have using System.Web.Http;
I installed Visual Studio 2015 with the same user I'm using to run it (It's a personal computer and I'm the single user) and am running it as administrator.
If you need any extra information please leave a comment and I'll edit the question.
Update-Package in Package manager console
may sort it out if it is a missing / mismatched package issue
I had the same issue a few months ago. In my case the following two steps worked:
1) Delete the hidden .vs folder from the solution folder, it's next to the .sln file (but close visual studio first)
2) From the .csproj file, remove these entries (if they exist)
<RestorePackages>true</RestorePackages>
And
<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('..\packages\Microsoft.Bcl.Build.1.0.21\build\Microsoft.Bcl.Build.targets')" Text="$([System.String]::Format('$(ErrorText)', '..\packages\Microsoft.Bcl.Build.1.0.21\build\Microsoft.Bcl.Build.targets'))" />
</Target>
I ended by creating a new project and just copying the files and only a few lines of configurations I needed from the old project and that solved it for me.
Related
Ran into this issue again, but the previous solution doesn't apply (removing Microsoft.Net.Compilers v3.8.0 via Nuget - this package doesn't exist in this solution)...
We have a VS2019 solution that we just replaced the old Microsoft FXCop Code Analyzers (3.3.x) with the newer Microsoft.CodeAnalysis.NetAnalyzers (5.0.3) via Nuget.
We are using the build agent on a TFS 2015 Update3 server. The server has VS2019 and Build Tools, all updated to latest. The same as on our development machines.
The solution built just fine with the old/deprecated analyzers, but now throws an error with the new analyzers. The error is:
[ProjectPath]\src\packages\Microsoft.CodeAnalysis.NetAnalyzers.5.0.3\build\Microsoft.CodeAnalysis.NetAnalyzers.props (1): The default XML namespace of the project must be the MSBuild XML namespace.
If the project is authored in the MSBuild 2003 format, please add xmlns="http://schemas.microsoft.com/developer/msbuild/2003" to the <Project> element.
If the project has been authored in the old 1.0 or 1.2 format, please convert it to MSBuild 2003 format.
I have verified all projects in the solution do, in fact, have the recommended namespace in the [project] element. In doing some experimentation and research, something appears to be overriding the normal TFS 2015 compiler version. I cannot figure out what it would be.
NOTE: I went back to FXCop Code Analyzers 2.9.12 and everything builds in TFS just fine. When I tried to use 3.3.x, I get the same build error again. Not sure what that means.
We would like to get off the old/deprecated analyzers. Any and all help is very much appreciated.
To make the tfs build use the msbuild.exe of VS2019. You can try editing your build template .xaml to set the ToolPath to the location of the msbuild.exe which is in visual studio 2019 pro.
ToolPath="C:\Program Files (x86)\Microsoft Visual Studio\2019\Professional\MSBuild\Current\Bin"
Or, you can edit TFSBuildServiceHost.exe.config file to make MSBuild task to use a specific MsBuild Location. See below:
<msbuildToolsets>
<toolset toolsVersion="16.0">
<property name="MSBuildToolsPath" value="C:\Program Files (x86)\Microsoft Visual Studio\2019\Professional\MSBuild\Current\Bin" />
</toolset>
<toolset toolsVersion="latest">
<property name="MSBuildToolsPath" value="C:\Program Files (x86)\Microsoft Visual Studio\2019\Professional\MSBuild\Current\Bin" />
</toolset>
</msbuildToolsets>
You can refer to below threads for more information.
how to select which MSBUILD.exe is used
Build VS2017 project with TFS 2012 build server
I have a Visual Studio 2015 C# project consuming packages from NuGet. The solution contains several C# projects and is checked out on drive C.
Problem: I cannot compile the solution or restore nuget packages since several hours. I get the following error:
NuGet Package restore failed for project ...: The file or directory is
corrupted and unreadable.
The Package Manager Console reports the following error after startup:
The file or directory is corrupted and unreadable.
Restarting Visual Studio does not fix the issue. Accessing the files with File Explorer and Notepad++ works. I don't experience any internet connectivity issues. Nuget seems to be online.
There is no private nuget registry in use, the default package source https://api.nuget.org/v3/index.json is used.
Visual Studio 2015 Professional 14.0.25431.01 Update 3
Package Manager Console Host Version 3.6.0.2511
VS 2015: C# NuGet Package restore failed. The file or directory is corrupted and unreadable
Please try the following troubleshootings to fix this issue:
Remove all nuget packages under \packages folder, then go to the solution in Visual Studio and press "Restore Nuget Packages", rebuild your solution.
Go to Tools->Extensions and Updates->Installed, uninstall the NuGet Package Manager for Visual Studio 2015, and reinstall it.
Hope this helps.
It may be the file system error in the drive
I use system drive tool to check and fix the error
windows file system error check tool
While Opening VS 2015 project in VS 2017 getting this error of Install Missing Features
When I press on Install button the loader comes and then the error comes, after that nothing happens
Visual Studio 2017 Version Details
Stuffs Tried till now
Link 1 : Installed Microsoft Expression Blend Software Development Kit (SDK) for .NET 4
Link 2 : Not able to do any of the steps given in this link
Link 3 : Have done this setting to set proxy settings for VS2017
Env Info
Using Corporate account having proxy settings to access internet
Please help on how to proceed ahead.
This can be caused by having the Nuget Package "Microsoft.CodeDom.Providers.DotNetCompilerPlatform" installed for a project, without actually having all the package files present. (I don't know how this happens.)
Edit the project file of the unloaded project (right-click in Solution Explorer > edit). Remove this line near the top:
<Import Project="$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props" Condition="Exists('$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props')" />
Right-click the project again > Reload Project.
Visual Studio might prompt you to restore Nuget packages. Click yes.
If it doesn't prompt you, right-click the solution in Solution Explorer > Restore Nuget Packages.
I have an error in one of my projects at work. The error says:
Severity Code Description Project File Line Suppression State
Error The "StyleCopTask" task could not be loaded from the assembly
C:\Projects\Project
Name\Source\\MSBuild\StyleCop\v4.7\StyleCop.dll. Could not load
file or assembly 'Microsoft.Build.Utilities.v3.5, Version=3.5.0.0,
Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a' or one of its
dependencies. The system cannot find the file specified. Confirm that
the declaration is correct, that the assembly and all its
dependencies are available, and that the task contains a public class
that implements
Microsoft.Build.Framework.ITask. DskDirectMarketing.Common
Here I can clearly see that there is problem in the relative path which VS is looking for StyleCop. Here is how it looks like:
<Import Project="$(SolutionDir)\MSBuild\StyleCop\v4.7\StyleCop.targets" />
and my SolutionDir declaration looks like this:
<SolutionDir Condition="$(SolutionDir) == '' Or $(SolutionDir) == '*Undefined*'">..\</SolutionDir>
After some digging I noticed that in the error which prompts me there are 2 slashes:
C:\Projects\Project Name\Source\MSBuild\StyleCop\v4.7\StyleCop.dll
First thing I tried was to remove the dash from
<Import Project="$(SolutionDir)MSBuild\StyleCop\v4.7\StyleCop.targets" />
Id didn't worked.
After that I tried to put the absolute path but I had 2 slashes again.
How can I resolve this issue? Any help would be appreciated.
Based on #MaKCbIMKo's answer I installed .Net Framework 3.5 and this fixed my problem.
If you are using Windows 10, enable the .net framework 3.5 and if does not allow you to do so, open command prompt and run:
Dism /online /enable-feature /featurename:NetFX3 /All /Source:D:\sources\sxs /LimitAccess
If you're also using Visual Studio 2019 on Windows 10, you could try the following:
Close your Visual Studio instance.
Open Visual Studio Installer.
On the version of Visual Studio that you're currently using, click on More and select Modify.
Select the Individual components tab.
Search for .NET Framework 3.5 development tools, select it and click on Modify.
Wait for the modification to finish.
Open your project in Visual Studio, then do a Clean, followed by a Build.
In my case the paths were correct, but visual studio needed to run under elevated permissions to access the file in question.
We need to use visual studio installer to install the .netframework 3.5 , if the visual studio installer shows both options Visual Studio 2019 and Visual studio Build Tools 2017. follow below step
If you are using the Visual Studio 2019 ( mine was 16.11.3 but should work for all the versions). you will have Visual studio 2019 and Visual studio build tools 2017 .
Select the Visual Studio Build Tools 2017 => select modify => go to individual components => select .Net Framework 3.5 development tools
Then proceed with the installation.
-Ideally it should work once you re open the Visual studio , if not restart the system
I downloaded visual studio community 2015. I tried to create a Shared Project and am getting an error:
Content from Microsoft.Windows.UI.Xaml.CSharp.targets
<Project xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<PropertyGroup Condition="'$(TargetPlatformVersion)'==''">
<TargetPlatformVersion>8.0</TargetPlatformVersion>
</PropertyGroup>
<PropertyGroup Condition="'$(TargetPlatformIdentifier)' == 'UAP'">
<RedirectionTarget>8.2</RedirectionTarget>
</PropertyGroup>
<PropertyGroup Condition="'$(RedirectionTarget)' == ''">
<RedirectionTarget>$(TargetPlatformVersion)</RedirectionTarget>
</PropertyGroup>
<!-- Direct 8.0 projects to 8.1 targets to enable retargeting -->
<PropertyGroup Condition="'$(RedirectionTarget)' == '8.0'">
<RedirectionTarget>8.1</RedirectionTarget>
</PropertyGroup>
<Import Project="$(RedirectionTarget)\Microsoft.Windows.UI.Xaml.CSharp.targets" />
</Project>
I do not have folder with name 8.1
One workaround is to make the following edits:
Open the file %ProgramFiles(x86)%\MSBuild\Microsoft\VisualStudio\v14.0\CodeSharing\Microsoft.CodeSharing.CSharp.targets (for Visual Basic the file is Microsoft.CodeSharing.VisualBasic.targets) and look for the following entries around line 8 -
<Import Project="$(MSBuildExtensionsPath32)\Microsoft\WindowsXaml\v$(VisualStudioVersion)\Microsoft.Windows.UI.Xaml.CSharp.targets" Condition="Exists('$(MSBuildExtensionsPath32)\Microsoft\WindowsXaml\v$(VisualStudioVersion)\Microsoft.Windows.UI.Xaml.CSharp.targets')"/>
<Import Project="$(MSBuildBinPath)\Microsoft.CSharp.Targets" Condition="!Exists('$(MSBuildExtensionsPath32)\Microsoft\WindowsXaml\v$(VisualStudioVersion)\Microsoft.Windows.UI.Xaml.CSharp.targets')" />
Change these lines to the following -
<Import Project="$(MSBuildExtensionsPath32)\Microsoft\WindowsXaml\v$(VisualStudioVersion)\Microsoft.Windows.UI.Xaml.CSharp.targets" Condition="false"/>
<Import Project="$(MSBuildBinPath)\Microsoft.CSharp.Targets" Condition="true" />
Basically, undo the conditional import of the Xaml based shared projects.
This is (believe it or not) the advice I received from MS for this issue. I think it's related to an unclean upgrade of the RC (or earlier) versions to RTM and the selection of different options during install.
(Insert usual caveats about editing files that don't "belong" to you, take backups, and if you're not confident to make such edits, don't)
Try to copy 8.0 and 8.1 directories from C:\Program Files (x86)\MSBuild\Microsoft\WindowsXaml\v12.0 to C:\Program Files (x86)\MSBuild\Microsoft\WindowsXaml\v14.0 (notice version number at the end).
It seems that those are missing in 2015 installation on windows 7.
You'll need to restart Visual Studio after that.
To fix this issue install the Windows 8/8.1 Project templates.
All I did was:
Open VS 2015
Click File->New->Project
Choose the only
Project template under Windows 8
This will launch Visual Studio setup where you can install the templates that are missing.
Then you can create your Project.
This is not a hard problem. Mr. Kriper (the original asker of the question) likely installed using the "Default Install" for his version of Visual Studio 2015. Mr. Kondrasovas in Answer 2 points to needing to install more components. His approach resulted in a Visual Studio displaying a setup utility error which is no fault of Mr. Kondrasovas. Mr. Kondrasovas answer is likely correct if you do not encounter an error (I have no way to verify the answer).
The solution is to go to Control Panel | Programs | Uninstall a program. Select Visual Studio 2015 and "Modify" the installed instance of Visual Studio 2015:
[sorry I cannot show the image b/c I do not have a 10 for a reputation and StackOverflow.com is blocking me]
The previous (imaginary) screenshot is from the default install of Visual Studio 2015 Professional. You can mess around and figure out the exact feature to install or if you have the disk space, simply click on "Select All" and then "Next". Hint: the "Next" button is not enabled until a change is made to the selected components of Visual Studio 2015.
If you want to see the missing image a complete write up, I wrote a blog post on the issue: http://www.softwarepronto.com/2015/08/visual-studio-2015-error-adding-shared.html