将具有NuGet依赖项的.NET项目添加到git仓库中的正确方法是什么? [英] What is the right way to add .NET project with NuGet dependencies to a git repo?

查看:105
本文介绍了将具有NuGet依赖项的.NET项目添加到git仓库中的正确方法是什么?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

例如,我有一个项目正在编写NUnit测试.我想将代码提交到git,但是我也觉得将NuGet包(NUnit和NUnit.Runner)提交到仓库是一种不好的做法.但是,我也不希望同时打开Package Restore,因为我认为这是用户设置而不是项目设置(IIRC).

I have a project(s) that I'm writing NUnit tests for (for example). I want to commit the code to git, but I also feel it's bad practice to commit the NuGet packages (NUnit and NUnit.Runner) to the repo. However, I don't want to also turn on Package restore either since I believe it's a user setting and not a project setting (IIRC).

将具有NuGet依赖项的.NET项目添加到git存储库的正确方法是什么?我认为这将是一件令人愉快的事情,但是需要开发人员的干预.也许只是希望其他开发人员知道将那些缺少的软件包重新添加到项目中? (似乎我们最终也总是会解决.csproj冲突).

What is the right way to add .NET project with NuGet dependencies to a git repo? I assume it would be something that would happily grab the Packages but one that requires developer intervention. Perhaps just expect other developers to know to add those missing packages back into the project? (It also seems like we'd end up resolving .csproj conflicts all the time too).

推荐答案

如果无法或不愿意启用软件包还原,则开发人员可以通过命令行轻松添加所有软件包,如

If unable or unwilling to enable package restore, a developer can easily add all packages by command line, as explained in this question:

您可以使用nuget.exe还原软件包.为每个项目运行以下命令.

You can use nuget.exe to restore your packages. Run the following command for each project.

nuget install packages.config

您还可以在预构建命令中运行此命令,如

You can also run this in a pre-build command, as explained here:

$(SolutionDir)Tools\nuget install $(ProjectDir)packages.config

但是,实际上,还原软件包更容易,只需单击几下即可.

But really, package restore is easier, it merely requires a few clicks.

这篇关于将具有NuGet依赖项的.NET项目添加到git仓库中的正确方法是什么?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆