visual-studio


NuGet Packages are missing


I searched this problem but none of the solutions worked. I have Visual Studio Professional 2015 installed and I am using TFS. My NuGet version is 3.1.6. This problem is happening only in my C# Web API/MVC project.
I am getting the below 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.Net.Compilers.1.0.0\build\Microsoft.Net.Compilers.props
I do not have .nuget folder in my solutions.
I have a packages folder in the solution and when I delete it, it seems like NuGet does rebuild the dependencies but the project still has the above error.
I tried removing the project from TFS and it didn't fix it.
Along with the above error, all the references in the project have yellow warning signs and say they are missing.
When I checked the NuGet Package Manager for the project, everything that is "missing" has a green tick next to it, including Microsoft.Net.Compilers.
I tried adding a new Web API/MVC project and it faced a similar problem where most references such as Owin were "missing" with the yellow warning sign.
I had the same error (missing exactly the same package) today. I also created a MVC + Web API project.
It happend because I moved the app files (including the .csproj) file to another location. I manually updated the .sln file but all packages dependencies are now (Visual Studio 2015) stored in .csproj file.
Editing the .csproj file and correcting the relative path to the solution folder (which contains the packages folder) solved the problem for me.
i solved my issue by removing this code from .csproj file
<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>
If you have one more missing nuget package that giving your error while building your solution use following command using Nuget Command Console from Tools > Nuget Package Manager > Package Manager Console. It will reinstall your all current packages.
Update-Package –reinstall
I had this exact frustrating message. What finally worked for me was deleting all files and folders inside /packages and letting VS re-fetch everything the next build.
Tiberiu is correct. I had to edit my .csproj file as the files were moved and caused this issue
<Import Project="..\..\packages\Microsoft.CodeDom.Providers.DotNetCompilerPlatform.1.0.1\build\Microsoft.CodeDom.Providers.DotNetCompilerPlatform.props" Condition="Exists('..\..\packages\Microsoft.CodeDom.Providers.DotNetCompilerPlatform.1.0.1\build\Microsoft.CodeDom.Providers.DotNetCompilerPlatform.props')" />
I changed at top of the file and at the bottom
<Error Condition="!Exists('..\..\packages\Microsoft.Net.Compilers.1.0.0\build\Microsoft.Net.Compilers.props')" Text="$([System.String]::Format('$(ErrorText)', '..\..\packages\Microsoft.Net.Compilers.1.0.0\build\Microsoft.Net.Compilers.props'))" />
<Error Condition="!Exists('..\..\packages\Microsoft.CodeDom.Providers.DotNetCompilerPlatform.1.0.1\build\Microsoft.CodeDom.Providers.DotNetCompilerPlatform.props')" Text="$([System.String]::Format('$(ErrorText)', '..\..\packages\Microsoft.CodeDom.Providers.DotNetCompilerPlatform.1.0.1\build\Microsoft.CodeDom.Providers.DotNetCompilerPlatform.props'))" />
I solved this issue by removing the following code from .csproj file
<Target Name="EnsureNuGetPackageBuildImports" BeforeTargets="PrepareForBuild">
<PropertyGroup>
<ErrorText>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 {0}.</ErrorText>
</PropertyGroup>
<Error Condition="!Exists('..\..\..\Assemblies\NuGet\SpecFlow.Plus.Excel.1.4.2\build\SpecFlow.Plus.Excel.targets')" Text="$([System.String]::Format('$(ErrorText)', '..\..\..\Assemblies\NuGet\SpecFlow.Plus.Excel.1.4.2\build\SpecFlow.Plus.Excel.targets'))" />
I am using VS2012 and facing the same error. I removed the following Target tag from the .csproj file and it started compiling without any error.
<Target Name="EnsureNuGetPackageBuildImports" BeforeTargets="PrepareForBuild">
-- Error messages within Target Tag
</Target>
A combination of the 2 answers worked for me. First I modified the .csproj file to remove the reference to 1.0.0 version
< Target Name="EnsureNuGetPackageBuildImports" BeforeTargets="PrepareForBuild" >
----Error---
< /Target>
and then did
Update-Package -Reinstall
from the and it worked.
For me, the problem was that when I copied the solution to a new folder and opened it, it was missing the Nuget folder as shown below. I copied this folder over and everything worked. Note: This same folder was in our source control but not in this solutions project, it was up one directory.
The error message is completely correct. I tried all the tricks and none worked. The project (simple MVC Web App test) moved from Windows 8.1 VS 2015 Community to my new test box on Windows 10. All the latest updates to VS 2015 applied.
I could not even install any newer version of the compilers package.
Loop:
<LOOP>This seems to be a Ground Hog Day phenomena.</LOOP>
GoTo Loop
I finally just copied Microsoft.Net.Compilers.1.0.0 from the old project into the new one and it worked.
I could then start to update other packages to newer version.
Looks like a nuget project upgrade process bug to me.
NOTE: The original project was created in VS 2015 and does not have any legacy nuget methodologies.
For anyone who stumbles here with the issue I had (some but not all packages being restored on a build server), the final piece of the puzzle for me was adding a NuGet.config in the root of my solution, sibling to the .SLN file as David Ebbo explained here: http://blog.davidebbo.com/2014/01/the-right-way-to-restore-nuget-packages.html.
From Ebbo's blog post, the file contents for me are simply
<?xml version="1.0" encoding="utf-8"?>
<configuration>
<packageSources>
<add key="nuget.org" value="https://www.nuget.org/api/v2/" />
</packageSources>
</configuration>
UPDATE:
The NuGet API URL has changed for v3 (current as of Sept 2016). From https://www.nuget.org/
<add key="nuget.org" value="https://api.nuget.org/v3/index.json" />
To expand on a few of the answers here, yes you could remove the following block from your .csproj file:
<Target Name="EnsureNuGetPackageBuildImports" BeforeTargets="PrepareForBuild">
and this fixes the issue, however in my case, I noticed that I had additional references to the .NET.Compilers and .CodeDom.Providers with different versions:
<Error Condition="!Exists('..\packages\Microsoft.Net.Compilers.1.0.0
<Error Condition="!Exists('..\packages\Microsoft.CodeDom.Providers.DotNetCompilerPlatform.1.0.0\
<Error Condition="!Exists('..\packages\Microsoft.Net.Compilers.2.0.1
<Error Condition="!Exists('..\packages\Microsoft.CodeDom.Providers.DotNetCompilerPlatform.1.0.3\
When my packages.config only referenced the following:
<package id="Microsoft.Net.Compilers" version="2.0.1"
<package id="Microsoft.CodeDom.Providers.DotNetCompilerPlatform" version="1.0.3"
Removing the 1.0.0 items from the .csproj file fixed the issue.
I couldn't find any solutions to this so I added a copy of the nuget.exe and a powershell script to the root directory of the solution called prebuild.ps1 with the following content.
$nugetexe = 'nuget.exe'
$args = 'restore SOLUTION_NAME_HERE.sln'
Start-Process $nugetexe -ArgumentList $args
I called this powershell script in my build in the Pre-Build script path
Mine worked when I copied packages folder along with solution file and project folder. I just did not copy packages folder from previous place.
You can also use the suggested error message as a hint. Here's how, find the Manage Packages for Solution, and click on the resolve missing nuget package.
That's it
Solution that works in my case - Visual Studio 2015 Enterprice, project .NET 4.6.1
Upgrade to Update 3
Install Web developer tools
Just enable NuGet Package Restore. Right click your solution > choose 'Enable NuGet Package Restore'.
This will create the .nuget folder with NuGet.Config file and fixed my problem.

Related Links

adding asp application to Vs 2010 and debugging it
Visual Studio Command Prompt gives “\Common was unexpected at this time”
How to Create the Power Set (Combinations) of the Infinite Set in F# using Sequences?
Visual Studio 2010: CopyDirectory or xcopy to copy Whole Directory
32bit COMin VS 2010
The 32-bit version o fthe Visual Studio Remote Debugging Monitor cannot be used to debug 64-bit processes?
Unable to link in C++/CLI application
Is Entity Framewok installed with my Visual Studio 2010?
Include in project function sets the Build Action for some files to None
Driver menu not visible in Visual Studio 11
charting for Visual Studio 2010 Express
How to decrease the building time for Visual Studio
I am using visual studio as my main IDE.I want to format jscript code in visual studio but i didn't get option
Visual Studio won't load the website project if homepage is not working?
Access IIS 7.5 Express started by Visual Studio 2010 from VMWare Guest
Visual studio branches

Categories

HOME
oracle
mc
class
matrix
keyboard
mpdf
verification
enums
dafny
apk
nsis
cryptography
turbojpeg
mithril.js
stack-overflow
slide
bootstrap-switch
angular4
stimulsoft
android-contacts
rpmbuild
xsl-fo
android-permissions
gollum-wiki
mime-types
ipa
xdebug
list-comprehension
spring-annotations
infopath2010
epplus
lxml
creation
fastlane
windows-store
dagger
optionaldataexception
autorelease
rm
beeline
amazon-elastic-beanstalk
wolfram-language
android-async-http
django-redis
vimperator
seadragon
vim-plugin
lovefield
json-spirit
self
opencyc
dnx50
screen-orientation
wlanapi
postal-code
android-handler
whitespace-language
tidyr
datagridcomboboxcolumn
dc
roxy-fileman
map
insertonsubmit
jquery-transit
disjoint-union
lru
ui-design
icenium
email-verification
tridion-2011
chronometer
dropshadow
affinetransform
boost-foreach
servlet-container
printqueue
dip
downgrade
google-translator-toolkit
eai
accumulator
rakudo
twitter-feed
gui-designer
parentid

Resources

Mobile Apps Dev
Database Users
javascript
java
csharp
php
android
MS Developer
developer works
python
ios
c
html
jquery
RDBMS discuss
Cloud Virtualization
Database Dev&Adm
javascript
java
csharp
php
python
android
jquery
ruby
ios
html
Mobile App
Mobile App
Mobile App