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

Sourcecode for Paymentroll example in Robert C. Martin book [closed]
What is the best practices for directory structures in my Visual Studio project?
Programatically enforce capitalization in Visual Studio 2008?
Does Visual studio Team Foundation Server really need to be on it's own machine?
Disabling StyleCop rules
Insert Tracepoint: how to set the default message?
In Visual Studio (2008), can I start up a website debug session as the web root?
SetUnhandledException Filter
Access contact list to use e-mail address?
Visual Studio shortcut for showing dropdown of available Enum values for function argument
Windows Server (2003/2008) as a Development Machine?
Visual studio custom build step rule?
How to use IronPython with Visual Studio 2008
Where should external assemblies be place in my Visual Studio solution so that they are part of source control?
Visual Studio add-on gallery?
Why does Visual Studio 2005 take so long to update my VSMDI file?

Categories

HOME
azure-functions
swi-prolog
devexpress
message-queue
loopbackjs
whmcs
header
javafx-8
scheduler
timber
mailing-list
swarm
circleci
smartgwt
closures
cocos2d-android
chronicle-queue
crud
gravity-forms-plugin
acrobat
tsung
fatfs
docx4j
delayed-job
knights-tour
ms-media-foundation
spring-rabbitmq
amazon-kms
aurelia-cli
aurelia-http-client
rdp
python-jira
slideshow
pyttsx
httphandler
web-inspector
apache-toree
xcode8.2
music21
adblock
password-hash
skip-lists
android-webservice
android-mediarecorder
word-2007
1010
rustdoc
wildfly-9
d3v4
dcount
ajaxmin
highlighting
apple-configurator
django-redis
verisign
gridbaglayout
ui4j
ibm-was
largenumber
dnx50
green-threads
alwayson
artisan
ampersand
subfolder
fiware-bosun
juttle
quantify
otl
coding-efficiency
forceclose
iosched
code39
hints
chartfx
itunes-sdk
tridion-2011
clrprofiler
image-formats
first-class
kolite
multidrop-bus
boost-foreach
radscheduler
botnet
activestate
tacit-programming
inversion
accumulator
sqlsitemapprovider
rootkit

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