I have a Nuget package. Example: 'Sample'.
I have generated a .nupkg file using nuspec file.
and then pushed 'Sample' nuget package to feed using Nuget push azure build task.
my nuspec file:
<?xml version="1.0" encoding="utf-8"?>
<package xmlns="http://schemas.microsoft.com/packaging/2010/07/nuspec.xsd">
<metadata>
<id>Sample</id>
<version>1.0.0.0</version>
<title>Sample</title>
<authors>Name</authors>
<copyright>Copyright © 2009-2019. All rights reserved.</copyright>
<tags>Sample</tags>
<description>This package is for testing.</description>
<owners>Name</owners>
</metadata>
<files>
<file src="./Sample.dll" target="lib\net46\Sample.dll"/>
</files>
</package>
Now I want to change the name of my nuget package, For example: 'SamplePackageForTesting'.
Nuget pakage name is not updated eventhough I change the title, and then pushed.
But when I change the id and push, then it is updating as new package.
Can you provide any solution how to change the name of my nuget package 'Sample' to 'SamplePackageForTesting'.
A rename is not possible: from NuGet's perspective, Sample and SamplePackageForTesting are two different packages as they have different IDs.
If you're using nuget.org, a workaround would be to deprecate your package (see here).
And if the NuGet feed is under your control you could also delete the Sample package. But for this, you have to make sure that nobody ever consumed it because otherwise deterministic builds won't be possible when going back in Git history.
Related
I recently migrated my projects from using PackageReferences to a package.config file. For awhile I've been able to call nuget.exe restore ...\Solution.sln and everything has looked fine. Now when I build I appear to be missing references to my packages used in my package.config files.
I removed all of the 'PackageReferences' from the .csproj file and added a 'packages.config' to each project that look like the following:
Ex 1:
<?xml version="1.0" encoding="utf-8"?>
<packages>
<package id="Newtonsoft.Json" version="13.0.1" targetFramework="net31"/>
</packages>
Ex 2:
<?xml version="1.0" encoding="utf-8"?>
<packages>
<package id="AspNetCore.HealthChecks.SqlServer" version="3.2.0" targetFramework="net31"/>
<package id="Newtonsoft.Json" version="13.0.0" targetFramework="net31"/>
<package id="System.ServiceModel.Security" version="4.9.0" targetFramework="net31"/>
</packages>
I have Automatically check for missing packages during build in Visual Studio checked in the NuGet Package Manager options of Visual Studio. I am using Visual Studio 2019 16.11.15 and NuGet 6.2.0.
Going to package manager and putting in update-package -reinstall outputs No package updates are available from the current package source for project 'ProjectName'.
If I right-click a packages.config file and select Migrate packages.config to PackageReference... I get an Operation Failed error. Is something wrong with my packages.config files? Is there anything else I can check?
Edit: I have attempted to delete all of my .vs, obj, and bin files. Also my csproj files begin with either <Project Sdk="Microsoft.NET.Sdk"> or <Project Sdk="Microsoft.NET.Sdk.Web">
We can only see migrate from packages.config to PackageReference in offical documatation because PackageReference is something newer. Reverse migration is not a good option.
You said you want to use packages.config with nuget restore so all dependencies can always be downloaded/updated after a fresh pull. You can refer to this page, it gives us many methods to restore packages.
For example, you can use “msbuild -t:restore” in PackageReference to restore packages. See this.
I'm using Octopack / Nuspec file to build my nuget package.
I would like to exclude certain folders which exist in the project. e.g. the "obj" file. I've been trying to get the exclude tag to work, but haven't had any luck. The nuget file builds, but the folder is still there.
Sadly, all the examples on the net specific file types and not folder.
<?xml version="1.0"?>
<package xmlns="http://schemas.microsoft.com/packaging/2010/07/nuspec.xsd">
<metadata>
<id>Foo</id>
<title>Foo</title>
<version>$version$</version>
<authors>NA</authors>
<owners>NA</owners>
<licenseUrl>http://Foo</licenseUrl>
<projectUrl>http://Foo</projectUrl>
<requireLicenseAcceptance>false</requireLicenseAcceptance>
<description>Foo</description>
<releaseNotes>NA</releaseNotes>
</metadata>
<files>
<file src="obj\**\*.*" exclude="*.*" />
</files>
</package>
I needed to create a WebApplication, but deploy it as a standard ASP.NET website using "CodeFile" attributes.
This was basically to update a page in the standard ADFS login site.
<files>
<file src="**" exclude="**\*.dll;**\*.designer.cs;**\*.csproj;**\*.pdb;**\*.user;**\*.vspscc;bin\*.cs;bin\*.aspx;bin\*.config;bin\*.asax;bin\*.pubxml" />
</files>
To directly answer the posters question, if you want to exclude only the obj folder from a Nuget package use the following in your nuspec xml
<files>
<file src="*\**" target="\" exclude="obj\**\*.*"/>
</files>
Depending on the project you are building, you shouldn't need to exclude anything.
If you are building a Windows Service/Console application, OctoPack should only package your bin\release directory.
If you are building a web application, you should use a 'publish' command to have MSBuild sent the binaries and content files to a temporary folder, and OctoPack will package that. This way your obj folders and C# files won't be packaged.
For information on how to do this, please see the section on Web Application Publishing at:
http://octopusdeploy.com/documentation/packaging/octopack
I am currently creating a nuget package with a nuspec file but getting the following error:
An item with the same key has already been added.
My command I am using is:
nuget pack "MyProject.csproj" -o "..\Packages"
This is my nuspec file:
<?xml version="1.0"?>
<package xmlns="http://schemas.microsoft.com/packaging/2010/07/nuspec.xsd">
<metadata>
<id>$id$</id>
<version>$version$</version>
<title>$title$</title>
<authors>$author$</authors>
<owners>$author$</owners>
<requireLicenseAcceptance>false</requireLicenseAcceptance>
<description>$description$</description>
<language>$language$</language>
</metadata>
<files>
<file src="bin\MyLibrary*.dll" target="lib\net45" />
</files>
</package>
The nuspec file I am using is also used when packaging other packages withing the same library. Could this be the reason why the above error is occurring? Any ideas?
It might be that you are adding files in nuspec that are also getting added when you call pack on the .csproj (files/dlls referenced by the csproj). If so you can remove the file references from the nuspec file and give it a try.
how does your nuspec file look like?
I created it with the following steps
1. create the Mylibrary project
2. let me add a dependency, I installed ninject package to the project
3. build
4. nuget spec mylibrary.csproj
5. nuspec file generated, I didn't add any file or dependency manually to the file
6. nuget pack mylibrary.csproj
7. nuget pack would automatically add ninject as a dependency and also add mylibrary.dll into the correct folder
8. http://npe.codeplex.com/ is a nice tool to open the nupkg file and see what got generated inside the package.
I had this error trying to use the package visualizer and it ended up that my packages.config had the same package name in it more than once with different versions.
I created a nuspec file:
<?xml version="1.0"?>
<package xmlns="http://schemas.microsoft.com/packaging/2010/07/nuspec.xsd">
<metadata>
<id>MyPackage.dll</id>
<version>3.5</version>
<authors>Me</authors>
<owners>Me</owners>
<requireLicenseAcceptance>false</requireLicenseAcceptance>
<description>The description</description>
<tags>tag1</tags>
</metadata>
</package>
In a directory with the file strucutre
MyPackage
Assemblies
MyPackage.dll
MyPackage.nuspec
I created my package using nuget.exe pack myPackage.nuspec and placed it in my local sources. I can find and install it from visual studio at which point
The dll is copied into the packages directory
But the reference is not added to the project
No repositories.config is created
No packages.config is created
What am I missing?
In case someone runs into this in the future. The solution was that the 'Assemblies' directory needed to be renamed 'lib'. The documentation was wrong (been updated, now it's correct).
Big thanks to dotnetjunky over on codeplex
I set up a local nuget package repository and create a custom package.
I followed these two guides:
http://nuget.codeplex.com/wikipage?title=Hosting%20Your%20Own%20Local%20and%20Remote%20NuPack%20Feeds
http://nuget.codeplex.com/documentation?title=Creating%20a%20Package
and here is the nuspec file of my package:
<?xml version="1.0" encoding="utf-8"?>
<package>
<metadata>
<id>NLog</id>
<version>1.0.0.505</version>
<authors>NLog</authors>
<description>NLog</description>
</metadata>
<files>
<file src="NLog.dll" target="lib"/>
</files>
</package>
the package was successfully created and the package shows up the package library.
But nothing happens when I click "INSTALL".
Can anyone help?
Looks like there was an issue with package building (Maybe the dll file didn't make it into lib). Try unzipping the package (rename to zip and extract) and seeing what's inside. We've updated nuget.exe and have added a -v flag to pack so that you can see the contents of your package after you build. You can install it from the ci machine http://ci.nuget.org:8080/guestAuth/repository/download/bt4/.lastSuccessful/Console/NuGet.exe).