I have a solution that looks like this:
-> Proj A
-> proj B
Proj B references Proj A
Both projects have a paket.template that looks like this:
When I paket pack, I get two nugets created, one for each project. Fantastic.
However, I now want to make ProjA.dll be bundled inside ProjB's nuget (ProjB is an .exe/tool that needs its dependencies bundled to operate).
Adding include-referenced-projects true to ProjBs paket.template has no effect, neither does any combination of paket command line --include-referenced-projects true that I've tried.
Is this supported? Is this a bug?
Either way, how can I achieve what I want, without making separate solutions to house ProjA and ProjB?
If you look at ProjB.nuspec from resulting nuget package you see nuget reference to ProjA package. So resulting ProjB package has all needed dependencies.
You can achive what you want by several ways:
Pack ProjB by command paket pack <output> --template <path to ProjB paket.tempplate> (without --include-referenced-projects flag). Pack ProjA by separate command if you need it.
Delete paket.template from ProjA, then pack ProjB with --include-referenced-projects flag. But in this case package for ProjA will not be created.
Change paket.template type for ProjB from "project" to "file" and specify all dependencies and files manually.
(HACK:)) you can rename paket.template for ProjA from paket.template to <somethingElse>.template and pack ProjB with --include-referenced-projects flag.
Paket will not find than ProjA produce nuget package and add it as binary dependency to ProjB. You still can pack ProjA with separate command paket pack --template "path to <somethingElse>.template"
Related
I have to tag every .dll with it's version from assembly,
so from Service.dll it becomes: Service-v1.0.0.21455.dll
I tried this two approaches, but each has flows:
Build > Rename > Pack with nuget pack Service.csproj
The challenge is that after I do so, Nuget can't find missing Service.dll
Of course, because it's bin/Release/Service-v1.0.0.21455.dll
Build > Rename > Pack with nuget pack .nuspec
Issue I'm facing here is that dependencies are missing withing the nuget package
This is brief explanation, let me know if it's 'even possible'/'make sense'/'you need more details'
I have two projects
A.csproj
B.csproj
where B references A (reference to project in solution)
I want to automate creation of packages, where package B will contain dependecy to package A
I've generated nuspec using nuget spec A.csproj and created package using nuget pack A.csproj. The same for project B.
however B.nuspec does not contain dependecy to nuget package A?
I want to automate creation of nuget packages on TFS build server, where assembly version is determined at build time.
In package B, how to add dependency to package A with correct version?
Firstly, to add the referenced projects as part of the package, you need to use the IncludeReferencedProjects option.
The command line is something like "nuget pack A.csproj -IncludeReferencedProjects"
Secondly, as you want to create NuGet packages during TFS build process, you need to create one PowerShell script which is similar to the followings, and include the PowerShell script in the Pre-build script (Assume you're using TFS2013 or TFS2015).
$projectFile = "project.csproj"
$nugetPath = “NuGet.exe"
$version = $Env:TF_BUILD_BUILDNUMBER
Write-Host ("packing $projectFile...")
& $nugetPath pack "$projectFile" -Version $version -Symbols -IncludeReferencedProjects
I tried to create .nuspec file in a different folder by giving path but
it is giving me error
Nuget.exe spec ..\MYDEMOFOLDER
Nuget.exe pack ..\MYDEMOFOLDER\MYPROJECT.csproj
pause
want to create MYPROJECT.nuspec in ..\MYDEMOFOLDER folder location
getting error to create nuspec file
The package ID '..\MYDEMOFOLDER' contains invalid characters. Examples of valid package IDs in
clude 'MyPackage' and 'MyPackage.Sample'.
Unfortunately nuget.exe spec doesn't work like that. It expects a package ID.
If you need to create a nuspec in a given folder, you will need to change to that directory.
pushd ..\MYDEMOFOLDER // switch to new directory (remember current)
nuget spec MYPROJECT // create MYPROJECT.nuspec file
nuget pack MYPROJECT.csproj // pack MYPROJECT.csproj
popd // return to previous directory
NOTE: If you're going to pack a project file, you don't need to create a nuspec file, as nuget will create one automatically.
navigate to the directory you want to create the file
download this nuget exe in the directory
cd to the directory on command line
use the command "nuget spec project.csproj"
check your directory for the generated nuspec file
Generate .nupkg file using below command
nuget pack MYPROJECT.csproj
change the .nupkg file extension to .zip.
Open the zip you will see the .nuspec file.
Dotnet has quite confusing similar arguments
--output
is used for output for build = input for nuget pack
/p:OutputPath=
is used as output folder of nuget pack itself
Example:
dotnet pack -c Release -p:PackageVersion=1.2.3 YourProject.csproj --no-build --output c:\outputofbuild /p:OutputPath=c:\outputfornuget
I am currently trying to publish a load of nuget packages for all the projects in this solution. The projects are setup in a simple tree, with Myre being the base project and everything depending on it:
Myre <- Myre.Debugging <- Myre.Debugging.UI <- Myre.UI
Myre <- Myre.UI
Myre <- Myre.Entities <- Myre.Graphics
I'm trying to package up each separate project as a nuget package with the correct dependencies on the other Myre subproject packages as necessary.
My first step was to make a package for Myre (nuspec and bat file of process). This seems to work nicely, the gallery shows Myre as having a ninject (another nuget package) dependency and all is well.
The problem comes when I tried to make the next package. Myre.Debugging depends upon Myre (with a normal project reference) and nothing else. Using this nuspec with nuget pack (verbose) gives:
Attempting to build package from '(x86) Myre.Debugging.csproj'.
Packing files from 'C:\Long_Path\Myre\Myre.Debugging\bin\x86\Release'.
Add file 'C:\Long_Path\Myre\Myre.Debugging\bin\x86\Release\Myre.Debugging.dll' to package as 'lib\net40-Client\Myre.Debugging.dll'
Add file 'C:\Long_Path\Myre\Myre\bin\x86\Release\Myre.dll' to package as 'lib\net40-Client\Myre.dll'
Add file 'C:\Long_Path\Myre\Myre\bin\x86\Release\Myre.XML' to package as 'lib\net40-Client\Myre.XML'
Found packages.config. Using packages listed as dependencies
Id: Myre.Debugging
Version: 1.0.0.2
Authors: Microsoft
Description: Description
Dependencies: Ninject (= 3.0.1.10)
Added file 'lib\net40-Client\Myre.Debugging.dll'.
Added file 'lib\net40-Client\Myre.dll'.
Added file 'lib\net40-Client\Myre.XML'.
Successfully created package 'C:\Long_Path\Myre\Myre.Debugging\Myre.Debugging.1.0.0.2.nupkg'.
As you can see it picks up a packages.config file (presumably from Myre since there isn't one here) which it then determines a Ninject dependency from. If I wanted Myre.Debugging and Myre to be a single package that would be fine. However this is not what I want, I want Myre.Debugging to pick up a dependency on the Myre package.
How can I setup nuget to use Myre as a package reference and not simply to copy the Myre assemblies into the Myre.Debugging package?
Edit:: I tried not using -IncludeReferencedProjects and specifying:
<dependencies>
<dependency id="Myre" version="1.0.0.1" />
</dependencies>
But for some reason this just creates a package with no dependencies at all! Even if manually specifying dependencies like this did work, it's hardly ideal.
According to the NuGet command line reference for the Pack command, the IncludeReferencedProjects switch works as follows:
Include referenced projects either as dependencies or as part of the package. If a referenced project has a corresponding nuspec file that has the same name as the project, then that referenced project is added as a dependency. Otherwise, the referenced project is added as part of the package.
In your case, Myre.Debugging.nuspec does not match the project file names: (x86) Myre.Debugging.csproj, etc. I suspect that you'll need to match up those file names to get that command line option to work.
Alternatively, if you want to get this to work with a <dependencies> element in your nuspec file, you may be facing another variant on the name mismatch problem. Your Myre.nuspec file defines its ID as follows:
<id>$id$</id>
The NuSpec reference says that the $id$ token is replaced by "The Assembly name." If it's talking about the name of the DLL (ignoring the extension), then I think the generated IDs will be (x86) Myre, etc. You might want to try hard-coding the ID temporarily just to see if that resolves the issue.
I haven't tried making these suggested changes, and I can't guarantee they will work, but I hope this points you in the right direction. Good luck!
Example:
Nuget package A is a set of code snippets (it does not contain an assembly).
Nuget package B is a normal assembly and it is using package A - just for internal means.
Question: What can I do, to avoid, that package A is also installed, when somone installes package B?
Found something in documentation of nuget:
Starting from version 2.7, the pack command will ignore entries in the packages.config file which have an attribute developmentDependency set to true and will not include that package as a dependency in the created package. For example, consider the following packages.config file in the source project
That seems to solve the problem.