My question is similar to this one. I have a solution, A, which contains projects B and C:
A
|-B ---> B.nupkg
| ^
|-C ------|
In the past, C used a project reference to B. Now, I've converted B so that it generates a NuGet package when I build (<GeneratePackageOnBuild>true</GeneratePackageOnBuild> in B.csproj), and I reference this in C. I do this because many consumers only want B but not C.
So now if I want to make a change to B and debug it, I have to do the following:
- Build the solution
- Copy
B.nupkgfrombin\Debugto a central location - Rebuild the solution again (and possibly clear my NuGet caches)
- Run
In past, with project references, all I had to do was build and run after chaning B and I could step through my newly changed code. How do I get back to the one-click process I had before with project references? Is there a way to use project references in Debug mode and NuGet packages in Release mode?
CodePudding user response:
It sounds like the projects B and C are in the same (or near-enough) location and solution (A); in that case, you're over-complicating this hugely.
Inside the solution, just use project references between B and C (in whichever direction you require). That's absolutely fine and expected - you can debug, build etc B and C together, and everything will work fine, without having to copy anything around during development. When you're ready to do a deployment for other consumers (either locally or via CI), just build everything together, making sure that both B and C are configured to generate NuGet packages (it sounds like you've already done this), and upload/copy both NuGet packages to your NuGet store, at the same time.
In the output nupkg files, the project references will be translated to NuGet package references automatically; you don't need to do anything.
