Empresas
Empregos
  • Sobre nós
  • Soluções
    • Publicação de vagas
      Publique sua vaga e receba candidatos qualificados em 48h.
    • Avaliações de candidatos
      Mais de 500 testes técnicos e psicológicos, mais anti-fraude.
    • Headhunting
      Busca executiva personalizada do início ao fim.
    • Folha de Pagamento + EOR
      Dispersão de folha e EOR em mais de 15 países da LATAM.
  • Preços
  • Empregos

0

296
Visualizações
How does nuget handle project references when publishing packages?

So for example lets say I have 2x csproj called A and B.

We have a project reference in B to A, so there are a few scenarios here and I cannot find information on how its handled:

Scenario 1 - Publish B when A isnt a published package

I assume in this case it would fail when trying to publish B because it cannot find a suitable dependency on nuget for A, although I am guessing here so clarification would be good.

Scenario 2 - Publish both packages independently

This is one of the more interesting scenarios, so lets say nothing has changed in A but we want to publish B, how does it translate the project reference from A to a nuget dependency on A? Does it just look for the latest build of A in nuget and add a dependency to that one?

Scenario 3 - Both packages are published together

This is one of the more common scenarios and in this case I can see that whenever you publish one package in the solution you also package new versions for everything else so their version numbers stay in line, this seems to create dependencies to all the same versions as expected here.


So scenario 1 and 2 are the main bits I am interested in as we started a discussion around if we should have project references vs package references between projects in the same solution, and if you are going to have package references to local projects it seems pointless, they may as well be in their own repo. So I just wanted to know how nuget handles the actual publishing so we can continue the debate with some facts around versioning etc.

over 4 years ago · Santiago Trujillo
1 Respostas
Responde à pergunta

0

It depends on the options you supply to the command to create the nuget package. You can either create it independently or create including referenced projects.

To include those that are referenced inside your project e.g for B to include A you can run the pack command with the following option:

nuget pack -Prop Configuration=Release -IncludeReferencedProjects

The option -Prop gives you the ability to set Configuration you want to apply when building the .nupkg. The option -IncludeReferencedProjects does include all the referenced project dependencies to the .nupkg file.

If your project is dependent on a another project/class library I would include it in the created nuget package. Otherwise why would you publish a broken package. If you publish them both separately then nuget should be able to resolve the dependency by installing it from the nuget source with the version you specified inside the B package. If it cannot find the specific reference version then it is a broken package, as Jon mentioned you would have to be careful to publish your package in proper sequence or all together. If your nuget cannot resolve it from nuget dependencies it will automatically include the dll if they exist in your solution.

over 4 years ago · Santiago Trujillo Relatório
Responde à pergunta
Encontrar trabalhos remotos

Descubra a nova forma de encontrar um emprego!

melhores empregos
Principais categorias de trabalho
Empresas
Postar vaga Preços Comercial
Jurídico
Termos e Condições Política de privacidade
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomende algumas ofertas para mim
Preciso de ajuda