We have an internal convention where if the CI/CD is doing a feature branch build, the NuGet package should be publish as "PackageId-FeatureBranchName". We publish these packages to a special feed that we don't reference in production builds. In our build script, if we detect we are doing a feature branch build, we look for any .nuspec files output by the build and the build would replace in the .nuspec file "" with "-FeatureBranchName" in all .nuspec files in the solution. This works fine if there is only one package with no dependencies on other projects in the solution.
Now I have two .NET Standard projects My.Assmebly.A and My.Assmebly.B that need to have their own NuGet packages. B depends on A. I am able to use the same build script above to set the of each package correctly. However, I am not sure of a solution to also update the .nuspec for package B to also update it's dependency on A to have the renamed My.Assmebly.A-FeatureBranchName.
Is there an easy way to script this. Or, I feel like I'm not doing this in the correct way with dotnet pack but I don't see any way to set package ids through command line or other, specifically when it comes to dependencies like this. I do see the $id$ token you can setup and replace. But I'm not sure how to use this now that .NET Standard projects generate their own .nuspec during the build. Nor do I think this will work with my dependency situation.
<?xml version="1.0" encoding="utf-8"?>
<package xmlns="http://schemas.microsoft.com/packaging/2012/06/nuspec.xsd">
<metadata>
<id>My.Assmebly.B</id>
<dependencies>
<group targetFramework=".NETCoreApp2.1">
<dependency id="My.Assmebly.A" version="1.0.0" exclude="Build,Analyzers" />
</group>
</dependencies>
</metadata>
</package>
Needs to look like this:
<?xml version="1.0" encoding="utf-8"?>
<package xmlns="http://schemas.microsoft.com/packaging/2012/06/nuspec.xsd">
<metadata>
<id>My.Assmebly.B-FeatureBranchName</id>
<dependencies>
<group targetFramework=".NETCoreApp2.1">
<dependency id="My.Assmebly.A-FeatureBranchName" version="1.0.0" exclude="Build,Analyzers" />
</group>
</dependencies>
</metadata>
</package>