0

I have projectA and projectB in the same solution.

projectA creates its own package, but I override the package id by using a prefix:

 <PackageIdPrefix></PackageIdPrefix>
 <PackageId>$(PackageIdPrefix)$(MSBuildProjectName)</PackageId>

The command to generate the package is :

dotnet pack  .\$(ProjectName).csproj  --include-symbols --no-build -o C:\dev\UPP\Packages -p:PackageIdPrefix=MyPrefix."

Therefore the generated package name is MyPrefix.ProjectA.nupkg

projectB references projectA as a project reference since they belong to the same solution. projectB creates its own package, in the same way:

   <PackageIdPrefix></PackageIdPrefix>
   <PackageId>$(PackageIdPrefix)$(MSBuildProjectName)</PackageId>

However in the nuspec of the generated MyPrefix.ProjectB.nupkg I end with :

  <dependency id="ProjectA" version="1.0.0" exclude="Build,Analyzers" />

So the prefix was not used to create the dependency in the nuspec. Obviously this leads to an error when I try to install this package since the dependency ProjectA does not exist...

How can I prefix the dependency ?

Sam
  • 13,934
  • 26
  • 108
  • 194
  • Does `` work? – ESG Jul 08 '20 at 20:41
  • I don't know, how could I test this ? The nuspec inside the package is auto-generated by the pack command. That's actually part of the problem I guess. – Sam Jul 08 '20 at 20:45
  • if you run `dotnet clean` and `dotnet pack -p:PackageIdPrefix=Blah` on your solution, you can test by installing ProjectB – ESG Jul 08 '20 at 20:50
  • yes, that's what i'm doing. But the prefix is only added to the name of the package being packed. The prefix is not added to the dependency. – Sam Jul 08 '20 at 20:55

0 Answers0