I am trying to create a nuget package from .net6 project xml file. I have added README.md into the project file. When I install the package in another project, I want the README file to be copied to the output directory. Since I m working with pipelines, I am directly creating packages from project file without separately creating nuspec file. Is there a way to add some property in the project file which enables copying readme files upon installation of package?
Related
I am still confused about how nuget works. I git clone a C# .sln project and from console, and I ran this nuget command:
nuget restore my_project.sln
it came to my attention that it generates two packages containing all dependencies required by my_project.
One package is located under my_project/src/packages, the other c:/users/my_user_name/.nuget/packages. While the file structures are a little different the DLL files in both packages are identical.
That confused me. Why two packages are generated by default? Where exactly does Visual studio look up for the project's dependencies?
More important, which config file should I update in order to only keep a copy of the dependencies and how can I specify the location in my file system for the packages?
Recent versions of NuGet support package references in project files.
This format will restore packages on demand, using your %USERPROFILE%.nuget folder as a cache. And your solution folder won't be "polluted" by a packages folder with binaries that you probably don't want to commit to source control.
VS2017 allows you to select "PackageReferences" or the older "Packages.Config" format when you create new projects (Tools/Options/NuGetPackageManager/General).
You probably have some projects in your solution that use the older "Packages.config" format, which stores in the packages folder in the solution directory, and newer "PackageReferences" format.
To convert the older projects to the new format, I believe you need to remove all packages from the project, then add them back again. They will be added using the default format you selected, with a prompt for confirmation if you selected "Allow format selection on first package install".
When I run a command like nuget install pdfsharp to add an external library to the project, the library is installed but as mentioned in the nuget documentation the command does not modify the project or packages.config.
Since I'm adding to an empty hello world, how do I create this packages.config file for nuget to later use nuget restore? I'm not finding in the documentation the format of this file.
nuget install Will add the package but will not modify the project or xml config, See - https://docs.nuget.org/ndocs/tools/nuget.exe-cli-reference
Installs a package into the current project but does not modify the project or packages.config.
Try using the powershell commandlets, See - https://docs.nuget.org/ndocs/tools/powershell-reference#install-package
Install-Package pdfsharp
I have several WCF and WebAPI services as well as MVC websites in a visual studio solution. Currently, we are creating WebDeploy packages for these services and websites to deploy to IIS. I'm starting to look into Octopus Deploy for deploying our services and websites instead of WebDeploy. However, Octopus Deploy uses Nuget packages to deploy.
I'm trying to figure out how I can easily create a Nuget package that contains all the files that would normally be published into a WebDeploy package. This may not be all files in the project directory or the bin directory. I found this blog post describing how to package a csproj into a Nuget package during the build, but I found that the resulting package didn't contain any of my dependency dll's. I realize I could write a nuspec for each of these projects manually and include exactly the files I want, but I'm looking for a more automatic way as this would create more maintenance when my project changes.
Does anyone out there know a good way to generate a nuspec or Nuget package that contains only the files needed to run the application, similar to the way publishing to a WebDeploy package only includes the files it needs?
Octopus Deploy has a CLI called "Octo.exe" that can package up your application into a NUPKG.
You will need to install Octopus Tools which you can download from https://octopus.com/downloads
Please see http://docs.octopusdeploy.com/display/OD/Using+Octo.exe for the documentation and how to use it.
A good example to use Octo.exe is part of a Continuous Integration pipeline when the build has successfully passed you call it to package the application and send it to the Octopus server.
After some playing around with Visual Studio, MSBuild, and TeamCity, I discovered a method that works for me. My issues was that I did not want to package up all the files in my project directory, only those that are necessary to run the application. WebDeploy handles this quite nicely as one of the options when publishing. I already have settings in my csproj file that will create a WebDeploy package on build, but this is a zip file and I don't want the zip file in my Nuget package.
I found 2 ways to deal with this:
In TeamCity, I set up a new Build Configuration that will package any nuspec files I have and publish the resulting Nuget packages to my Octopus Deploy Nuget feed. I figured out that I can use the existing WebDeploy package that gets created by my CI build configuration as an artifact dependency and TeamCity can actually unpack the zip file when grabbing the artifacts as part of that dependency. Then my nuspec file references the entire folder structure that was extracted from the zip file and packages it into a Nupak.
I was able to modify my csproj settings to use a specific publish profile I generated in Visual Studio that would perform a WebDeploy package to file system. This would result in the same folder structure as is in the zip file from #1, but simply copied to a directory. Then my Nuget build configuration could simply grab those dependencies and package them the same way as in #1.
I decided to go with option #1 as it would require minimal changes to my existing csproj and CI build configuration, and it would not break our current method of deploying using WebDeploy.
I have a C# project that uses Nuget for package management. I enabled package restore so it created the .nuget folder. Then I want to create a Nuget package of this project. Can I create nuget .nuspec files in the .nuget folder and modify the Nuget.targets file to allow the creation of the package and upload to the galery when I'm in release mode?
Thanks.
You can do that.
Alternatively you can use nuget.exe pack command in the post build event ( more details # http://docs.nuget.org/docs/reference/command-line-reference#Pack_Command )
or use true in the csproj file.
Is there a way to add specific folders in the project that the package is installed?
For example, according to this blogpost you can add multiple files to the project, but what I want to add are folders. I added folders in the content folder before I create my nuget package, but the folders are not added to the project after the package is installed.
Thanks !
If you create a directory hierarchy in the content folder, nuget will replicate that in your project.