简体   繁体   中英

In Visual Studio, how do I efficiently work with NuGet package source code

I have an application that references a NuGet package X. The source for X is under my control, ie, I manage the source and publish the artifact to a private NuGet repo.

I want to be able to be able to edit the source for X and have my application use assemblies built from that source instead the using the assemblies in the X's NuGet package.

Here was my workflow for this use case when I worked in Java/Eclipse:

  • Clone the repo for my application A
  • Clone the repo for X in a separate directory
  • In my Eclipse Workspace, create a project A, as well as one for X
  • In A, change the dependency version of X from 1.2.3 to 1.2.3-SNAPSHOT
  • Eclipse notices that it has a project in the workspace for X with version 1.2.3-SNAPSHOT, so it automatically builds X from source and uses that when running A

Can Visual studio do anything like that?

The only way to do this is to manually remove the reference to the nuget package X form your solution then add reference to the project X. The version number doesn't matter when you include a source project into your solution. Visual studio will automatically build the project X whenever a code change is made after the last dll was generated and you will be able to debug it as part of your solution. When you are finished with your changes, you can push the library into the private nuget server as a " pre-release " to signal it is still in testing phase. In Nuget manager inside visual studio you will have to check the option "include prerelease" to see it.

Edit: There is a dotnet command line tool that handles switching between project/nuget package and update all references automatically.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM