简体   繁体   English

在Visual Studio中,如何有效地使用NuGet包源代码

[英]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. 我有一个引用NuGet包X的应用程序.X的源代码在我的控制之下,即我管理源代码并将工件发布到私有NuGet仓库。

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. 我希望能够编辑X的源代码并让我的应用程序使用从该源代码构建的程序集,而不是使用X的NuGet包中的程序集。

Here was my workflow for this use case when I worked in Java/Eclipse: 以下是我在Java / Eclipse中工作时此工具的工作流程:

  • Clone the repo for my application A 克隆我的应用程序的回购A.
  • Clone the repo for X in a separate directory 在单独的目录中克隆X的repo
  • In my Eclipse Workspace, create a project A, as well as one for X 在我的Eclipse Workspace中,创建一个项目A,以及一个用于X的项目
  • In A, change the dependency version of X from 1.2.3 to 1.2.3-SNAPSHOT 在A中,将X的依赖性版本从1.2.3更改为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 Eclipse注意到它在X的工作区中有一个项目,版本为1.2.3-SNAPSHOT,所以它自动从源代码构建X并在运行A时使用它

Can Visual studio do anything like that? Visual Studio可以做那样的事吗?

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. 执行此操作的唯一方法是从您的解决方案中手动删除对nuget包X的引用,然后添加对项目X的引用。当您将源项目包含到解决方案中时,版本号无关紧要。 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. 每当在生成最后一个dll之后进行代码更改时,Visual Studio将自动构建项目X,并且您将能够将其作为解决方案的一部分进行调试。 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. 完成更改后,您可以将库推送到私有nuget服务器作为“ 预发布 ”,以表示它仍处于测试阶段。 In Nuget manager inside visual studio you will have to check the option "include prerelease" to see it. 在视觉工作室内的Nuget经理中,你必须检查选项“include prerelease”才能看到它。

Edit: There is a dotnet command line tool that handles switching between project/nuget package and update all references automatically. 编辑:有一个dotnet命令行工具 ,可以处理project / nuget包之间的切换并自动更新所有引用。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 如何设置Visual Studio来构建NuGet包? - How do I set Visual Studio to build a NuGet package? .NET / Visual Studio:如何查找给定包的NuGet包源 - .NET/Visual Studio: How to find NuGet Package Source for a given Package 如何在未安装 Nuget 或 Visual Studio 的 Web 服务器上安装、更新、注册 Nuget package? - How do I Install, Update, Register a Nuget package on the Web Server that does not have Nuget or Visual Studio installed? Visual Studio:NuGet 包源需要凭据 - Visual Studio : NuGet Package Source requires credentials 如何使Visual Studio正确地将Nuget包中的DLL放置在UWP应用中? - How do I get Visual Studio to properly place DLLs from Nuget Package in UWP apps? 如何让 NuGet package 恢复以处理存储在 VSIX 中针对 Visual Studio 2019 的本地部署包? - How do you get NuGet package restore to work on locally deployed packages stored in VSIX targeting Visual Studio 2019? 如何在visual studio中调试nuget包 - How to debug nuget package in visual studio 如何在Visual Studio中提供Nuget包的引用 - How to give reference of Nuget package in Visual Studio 如何在没有Visual Studio的情况下安装Nuget包? - How to install Nuget Package without Visual Studio? 无法从Visual Studio安装nuget源程序包 - Cannot install nuget source package from visual studio
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM