本文是小编为大家收集整理的关于使用NuGet和源代码控制的多人团队的处理/解决方法,可以参考本文帮助大家快速定位并解决问题,中文翻译不准确的可切换到English标签页查看源文。
问题描述
我团队中的另一个人做了最新的,所有的Nuget参考都对他失败了.
所以,我认为我需要添加包装文件夹.所以我做到了.
我这样做后,nuget参考仍在失败(对他来说).
另外,当我尝试将nuget软件包添加到文件时,我现在会遇到此错误:
访问路径'c:\ src \ mypath \ tomysolution \ packages \ repositories.config'被拒绝.
我认为这是因为 repositories.config 文件现已在源控件下(因此仅在手动检查之前读取).
所以,这是我的两个问题:
- 我如何或什么检查,以便Nuget软件包对我的同事有效,当他做最新时?
- 当我需要使用nuget时,是否有办法不必手动查看Nuget文件?
我做错了吗?还是Nuget并不是真正用于用于源控件?
推荐答案
编辑2014/03/31:不再需要基于手动MSBUILD的软件包还原启用启用,另请参阅 http://xavierdecoster.com/migrate-away-away-from-msbuild-noget-nuget-package-restore . .
编辑2012/02/07:现在是Nuget VSIX的内置功能,称为Enable Package Restore.
过时的替代
有一个Nuget软件包,称为NugetPowertools.它在Visual Studio中的Nuget Package Manager控制台中添加了两个新命令,其中enable-packagerestore是一个有趣的一个.
它将添加一个.nuget文件夹,其中包含nuget.exe,nuget.settings.targets和nuget.targets. 当您运行启用软件包还原时,它将列举解决方案中的所有项目,并在项目文件中添加 import nuget.targets 语句(实际上是MSBUILD文件本身).
每当您构建一个项目或整个解决方案时,Nuget都会按照packages.config文件中定义的该项目/解决方案获取所有软件包.这发生在一个前构建步骤中.
所以,简而言之:
- 请勿签入软件包
- 请签入配置文件(repositories.config and packages.config文件)
- 使用启用软件包还原
- 入住.nuget文件夹
每当有人获取来源时,无论是团队中的另一个开发人员还是构建代理,MSBuild过程都将被指示以在构建前步骤中获取任何必需的软件包.
另外,当软件包未投入到TFS源控件中时,您不会击中读取的flag 问题,也不会与二进制文件合并冲突.
如果需要,也可以检查此方法的底层推理我的博客.
其他推荐答案
不要检查包装夹.
将以下预建事件添加到您的项目:
$(SolutionDir)build\nuget install $(ProjectDir)packages.config -source \\server\path\NuGetPackages -o $(SolutionDir)packages
省略-source parameter如果不使用自定义软件包.
nuget.exe被选中到$(SolutionDir)build\nuget.
其他推荐答案
我总是只检查 packages.config 文件夹,然后使用 rake 开发人员(和构建服务器)可以使用的任务在本地更新软件包.
任务看起来像:
def nuget_for_project(project_dir) sh "tools\\NuGet.exe " + "i Source\\#{project_dir}\\packages.config " + "-o Source\\Packages" end namespace :nuget do desc "nuget for servicebus" task "ServiceBus" do nuget_for_project "SampleProject.ServiceBus" end desc "nuget for web" task "Web" do nuget_for_project "SampleProject.Web" end desc "nuget for all" task "all" => ["nuget:ServiceBus", "nuget:Web"] end
请注意,上面的脚本使用nuget.exe的本地版本,该版本已在源控件中检查到源控件中.
问题描述
I am on a two-man team using Team Foundation Server for our source control. I started a new solution. For that solution I created several projects. In many of them I used NuGet to install AutoMapper and Unity. I then right clicked on the solution and selected "Add to Source Control". I then checked in the resulting pending changes.
The other person on my team did a get latest and all of the NuGet references are failing for him.
So, I figured I needed to add the packages folder. So I did that.
After I did that, the NuGet references are still failing (for him).
Also, when I try to add a NuGet Package to a file I get this error now:
Access to the path 'C:\src\MyPath\ToMySolution\packages\repositories.config' is denied.
I assume this is because the repositories.config file is now under source control (so it is read only until manually checked out).
So, here are my two questions:
- How or what do I check in so that the NuGet packages are valid for my coworker when he does a get latest?
- Is there a way to not have to manually check out the NuGet files when I need to use NuGet?
Am I doing this wrong? Or is NuGet not really meant for use with source control?
推荐答案
Edit 2014/03/31: The manual MSBuild-based package restore enablement is no longer needed, see also http://xavierdecoster.com/migrate-away-from-msbuild-based-nuget-package-restore.
Edit 2012/02/07: This is now a built-in feature of the NuGet vsix, called Enable Package Restore.
Obsolete Alternative
There is a NuGet package for that, it's called NuGetPowerTools. It adds two new commands to the NuGet Package Manager Console in Visual Studio, amongst which Enable-PackageRestore is the interesting one for you.
It will add a .nuget folder which contains nuget.exe, nuget.settings.targets and nuget.targets. When you run enable package restore, it will enumerate all projects in your solution and add an import nuget.targets statement in the project files (which are actually msbuild files themselves).
Whenever you build a project or the entire solution, nuget will fetch all packages for that project/solution, as defined in the packages.config file. This happens in a pre-build step.
So, in short:
- do not check-in packages
- do check-in the config files (repositories.config and packages.config files)
- use Enable Package Restore
- check-in the .nuget folder
Whenever someone gets the sources, whether that's another developer in the team or a build agent, the msbuild process will be instructed to fetch any required packages in a pre-build step.
Also, when the packages are not committed into TFS Source Control, you won't hit the read-only flag issues, or merge conflicts with binary files.
If you want, you can also check-out the underlaying reasoning for this approach on my blog.
其他推荐答案
Don't check the packages folder in.
Add the following prebuild event to your project:
$(SolutionDir)build\nuget install $(ProjectDir)packages.config -source \\server\path\NuGetPackages -o $(SolutionDir)packages
Omit -source parameter if not using custom packages.
nuget.exe is checked into $(SolutionDir)build\nuget.
其他推荐答案
I always check in just the packages.config folder and use a Rake task that the developer (and build server) can use to update packages locally.
The task looks like:
def nuget_for_project(project_dir) sh "tools\\NuGet.exe " + "i Source\\#{project_dir}\\packages.config " + "-o Source\\Packages" end namespace :nuget do desc "nuget for servicebus" task "ServiceBus" do nuget_for_project "SampleProject.ServiceBus" end desc "nuget for web" task "Web" do nuget_for_project "SampleProject.Web" end desc "nuget for all" task "all" => ["nuget:ServiceBus", "nuget:Web"] end
Note that the above script uses a local version of NuGet.exe that is in a tools folder checked into source control.
You could write this for MSBuild or NAnt instead.
I wrote a longer blog post on this a while back that may be helpful.