I've created two NuGet package files
Foo.1.0.0.nupkg
Foo.1.0.1.nupkg
Both files are located in a folder on my PC, which I've configured as a package source in Visual Studio. I created a console app project which contains a NuGet.config file:
<?xml version="1.0" encoding="utf-8"?>
<configuration>
<config>
<!--
Used to specify the default location to expand packages.
See: NuGet.exe help install
See: NuGet.exe help update
-->
<add key="repositorypath" value="Packages" />
</config>
<packageRestore>
<!-- Allow NuGet to download missing packages -->
<add key="enabled" value="True" />
<!-- Automatically check for missing packages during build in Visual Studio -->
<add key="automatic" value="True" />
</packageRestore>
<packageSources>
<add key="Confused NuGet Packages" value="D:\NuGet Packages" />
</packageSources>
</configuration>
There is also a packages.config file associated with the solution, but there are no packages listed in that file, it's a blank canvas, which is fine.
When I look in the "Online" section in NuGet Package Manager, I can see both my custom packages, but regardless of which one I choose, when I click "Install" nothing happens. The package I choose is not installed.
Why is this?
Also, when I want to update a NuGet package, how can I do this and get the new package to appear in the "Updates" section of NuGet Package Manager? How can this be done?
I'm not 100% sure if this is the answer, but I did the following and the result is that my NuGet packages now appear in the "Installed" section, as well as the "Update" section after I create a new package.
First, for the class library DLL file I was using in the package, I added it to the "lib" special folder in NuGet Package Manager.
Also I made sure that the AssemblyVersion and AssemblyFileVersion details in AssemblyInfo.cs were correct for each version of the class library. After doing these two steps, everything clicked into place.
Related
I am having a hard time deploying my first .net core app with nuget references on the server. Locally, the app works absolutely fine (able to use nuget packages).
Apparently, there is no packages.config. I am using Dapper, Newtonsoft.Json, etc. Where is the project storing reference to these packages? There is no packages folder.
In the solutions folder, there is nuget.config file which for some reason is empty.
What should I add here
Unable to deploy app with nuget references on server
That because you are using the old version nuget restore task in the build pipeline, which only supports for the package management type packages.config not PackageReference.
That the reason why the old version task ask you to provide the path to the packages.config. The PackageReference is a follow-up product, so the previous version of nuget restore task does not support it.
Check the blog for some more details.
To resolve this issue, please use the V2 of the nuget restore task:
Note:
The PackageReference needs the nuget.exe 4.1 and above, please add
a NuGet tool installer to install the nuget version above 4.1.
Using .NET Core restore task should be also work for this issue.
Update:
Yes, using TFS 2016
Since you are using TFS 2016, you could try to use the command line to invoke the nuget.exe to restore the package instead of the nuget installer task:
Download the nuget.exe above 4.0 from the nuget.org, then set it on the TFS server.
Hope this helps.
You need to create a NuGet.config file that points to whatever NuGet feed you're using, add it to source control, and reference it in your build. I'll use the official feed for my example. This feed is already present by default if you're developing using Visual Studio, which might explain why the build runs locally but not on Azure DevOps.
At the very least, your NuGet.config file needs to look like this:
<?xml version="1.0" encoding="utf-8"?>
<configuration>
<packageSources>
<add key="NuGet.org Feed" value="https://api.nuget.org/v3/index.json" />
</packageSources>
</configuration>
In .NET Core, packages are now stored globally in your User directory. packages.config has been dropped in favor of the PackageReference node in a project file, so check your csproj to see the NuGets you're referencing.
You should use task dotnetcorecli task which has
#command: 'build' # Options: build, push, pack, publish, restore, run, test, custom
MS VS 2012
I have solution in tfs with enabled nuget packages restore. Every time when I build solution all my project files are cheked out with this changes:
<Import Project="$(SolutionDir)\.nuget\NuGet.targets" Condition="Exists('$(SolutionDir)\.nuget\NuGet.targets')" />
<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>
How to fix this behaviour?
As of NuGet v2.7, MSBuild-Integrated Package Restore has been deprecated and replaced with Automatic Package Restore.
See documentation on how to migrate your solution to the new feature: Migrating MSBuild-Integrated solutions to use Automatic Package Restore
To learn more about Automatic Package Restore see
NuGet Package Restore
Both articles discuss how this effects TFS integration.
Every time I create a new project, NuGet is adding a ton of packages that I don't want or need. I have tried uninstalling and reinstalling VS 2012, but somehow these packages keep coming back.
How do I completely remove them? If I uninstall NuGet, I get an error "NuGet.VisualStudio.Interop, Version=*, Culture=neutral ...
I then install NuGet, and all the old packages come back. I have no idea where this is being stored (registry?) but if I uninstall and reinstall Visual Studio, these should not be coming back.
Edit: I think I may have figured it out, but need confirmation. When I create a new, empty WebApplication, the packages are not added automatically. If I create a new, empty "Telerik MVC 4 Web Application", then I get the error shown in the picture below. I have set NuGet Package Manager to Allow NuGet to download missing packages and Automatically check for missing packages during build in Visual Studio, but I still get the error.
Edit/Solution: It turns out to be a problem with Telerik. I got this from support:
Is seems that you have ASP.NET and Web Tools 2013.1 installed.
Currently this update is not supported by our project templates. Until
we provide a support for ASP.NET and Web Tools 2013.1 I suggest you
convert an existing ASP.NET MVC Application to a Telerik UI for
ASP.NET MVC Application
This seemed to work.
The default list of NuGet packages are listed in the project templates.
You can find the templates here:
C:\Program Files (x86)\Microsoft Visual Studio 11.0\Common7\IDE\ProjectTemplates\CSharp\Web\1033
For example, if you choose MVC 4 Empty Web Application, the default packages are in the EmptyMvcWebApplicationProjectTemplate.11.cshtml.vstemplate file:
<packages repository="registry" keyName="AspNetMvc4VS11" isPreunzipped="true">
<package id="Newtonsoft.Json" version="4.5.11" skipAssemblyReferences="true" />
<package id="Microsoft.Web.Infrastructure" version="1.0.0.0" skipAssemblyReferences="true" />
<package id="Microsoft.AspNet.Razor" version="2.0.20715.0" skipAssemblyReferences="true" />
<package id="Microsoft.AspNet.WebPages" version="2.0.20710.0" skipAssemblyReferences="true" />
<package id="Microsoft.AspNet.Mvc" version="4.0.20710.0" skipAssemblyReferences="true" />
<package id="Microsoft.AspNet.Mvc.FixedDisplayModes" version="1.0.0" skipAssemblyReferences="true" />
<package id="Microsoft.AspNet.WebApi.Client" version="4.0.20710.0" skipAssemblyReferences="true" />
<package id="Microsoft.Net.Http" version="2.0.20710.0" skipAssemblyReferences="true" />
<package id="Microsoft.AspNet.WebApi.Core" version="4.0.20710.0" skipAssemblyReferences="true" />
<package id="Microsoft.AspNet.WebApi.WebHost" version="4.0.20710.0" skipAssemblyReferences="true" />
<package id="Microsoft.AspNet.WebApi" version="4.0.20710.0" skipAssemblyReferences="true" />
</packages>
BTW: These packages are actually needed since MVC4+ is now installed entirely via NuGet.
Anyway, you can explore the other templates there and edit the .vstemplate files to add or remove the default packages.
For more information, look here:
https://docs.nuget.org/docs/reference/packages-in-visual-studio-templates
http://www.xavierdecoster.com/update-project-template-to-latest-nuget-packages
Hope this helps.
I'm trying to install a custom ReSharper's plugin I wrote using the ReSharper Extension Manager but I get the error
Attempting to resolve dependency 'JetBrains.ReSharper.SDK (≥
8.2.1158)'.
Unable to resolve dependency 'JetBrains.ReSharper.SDK (≥ 8.2.1158)'.
I followed the official documentation and here is my .nuspec.
<?xml version="1.0"?>
<package >
<metadata>
<id>CustomMacro</id>
<version>1.0.0.0</version>
<title>Custom macro</title>
<authors>Me</authors>
<description>do something</description>
<copyright>Copyright © 2014</copyright>
<tags>Cool Plugin</tags>
<dependencies>
<dependency id="ReSharper" version="[8.2,8.3]" />
</dependencies>
</metadata>
<files>
<file src="bin\Release\*.dll" target="ReSharper\vAny\vs12.0\plugins" />
</files>
</package>
Note: The nuget packaged is pushed inside my company's nuget repository and when I search for the package in the Extension Manager I do it from Online -> All tag
That .nuspec file looks fine, but doesn't match the error message. The error message indicates that the .nupkg has a dependency on "JetBrains.ReSharper.SDK". ReSharper uses NuGet packages in a runtime capacity, so development dependencies shouldn't be included. When installing, ReSharper will try to resolve any dependencies and install them (as runtime extensions, not assembly references). The "JetBrains.ReSharper.SDK" package is a nuget assembly reference package, and isn't required, or available on ReSharper's extension package gallery, so it fails to install.
I'd suggest getting NuGet Package Explorer and double clicking on the .nupkg to see if it's got the same .nuspec as you've shown.
Also, you should be copying the *.dll files into ReSharper\v8.2\plugins. It can't live in vAny because ReSharper plugins are compiled against specific versions of ReSharper. And it should only go in the vs12.0 folder if it's specific to Visual Studio 2013, i.e. it uses VS2013 assemblies and functionality.
I have Project which references from NuGet repository Module of version 1.0.0.0.
For some time Module versions are changed to 1.1.0.0, 1.1.0.1, 1.1.1.0, 1.1.5.0, 1.2.0.0, 1.2.1.0. And my Project supports just 1.1.X.X versions set. And the latest version NuGet should upgrade Project reference is 1.1.5.0, but NuGet suggests 1.2.1.0.
Due this article: http://docs.nuget.org/docs/reference/versioning I need to modify packages.config of my Project and set 'allowedVersions' attribute:
<?xml version="1.0" encoding="utf-8"?>
<packages>
<package id="Module" version="1.0.0.0" allowedVersions="[1.1,1.2)" />
</packages>
Does NuGet supports constraints on minor versions?
NuGet version is 2.7.41101.299
can you please provide more details about your project type and the packages installed? or a simplified repro app is fine, which will help us diagnosis the issue.
Btw, the latest version of NuGet is 2.7.2, which can be downloaded at http://docs.nuget.org/docs/start-here/installing-nuget. Please see if your issue still reproes with the latest version. Thanks!