简体   繁体   English

Visual Studio自动还原DLL包

[英]Visual Studio auto restores dll packages

In the company I work, inside every solution we have one folder packages , which contains all dll dependencies. 在我工作的公司中,每个解决方案中都有一个文件夹包 ,其中包含所有dll依赖项。 This folder is not in repository with the rest of the solution. 该文件夹不在解决方案的其余部分中。

Every time I build one project, all files inside folder packages are restored and any missing dlls appear again. 每次我建一个项目,文件夹包装内的所有文件都恢复任何丢失的DLL再次出现。 This happens in the beginning of the build, no matter if the build succeeds of fails. 无论构建是否成功,都将在构建开始时发生。 Even if the project has no dll dependencies, any missing dlls in packages are restored. 即使项目没有dll依赖项, 程序包中所有丢失的dll也会还原。

I suspect it is a setting in msbuild but I cannot find it. 我怀疑这是msbuild中的设置,但找不到。 Does anyone know where it might be or if there is a place with msbuild *.targets files? 有谁知道它可能在哪里,或者是否存在msbuild * .targets文件的地方?

thanks for any help 谢谢你的帮助

This is because Visual Studio restores packages defined in the packages.config files. 这是因为Visual Studio还原了packages.config文件中定义的packages.config

You can control this behaviour in Visual Studio in options: 您可以在Visual Studio中的选项中控制此行为: VS NuGet选项

From the MS Docs regarding regarding Nuget: 来自MS Docs关于Nuget的信息:

MSBuild: use the msbuild -t:restore command, which restores packages packages listed in the project file (PackageReference only). MSBuild:使用msbuild -t:restore命令,该命令将还原项目文件中列出的软件包(仅PackageReference)。 Available only in NuGet 4.x+ and MSBuild 15.1+, which are included with Visual Studio 2017. nuget restore and dotnet restore both use this command for applicable projects. 仅在Visual Studio 2017附带的NuGet 4.x +和MSBuild 15.1+中可用。nuget restore和dotnet restore都将此命令用于适用的项目。

Further down, there's quite a bit about enabling/disabling and modifying this behavior in a variety of ways. 进一步讲,有很多关于以各种方式启用/禁用和修改此行为的信息。

Allow NuGet to download missing packages: controls all forms of package restore by changing the packageRestore/enabled setting in the NuGet.Config file as shown below (%AppData%\\NuGet\\NuGet.Config on Windows, ~/.nuget/NuGet/NuGet.Config on Mac/Linux). 允许NuGet下载丢失的软件包:通过更改NuGet.Config文件中的packageRestore / enabled设置,控制所有形式的软件包还原,如下所示(在Windows上为%AppData%\\ NuGet \\ NuGet.Config,〜/ .nuget / NuGet / NuGet .Config在Mac / Linux上)。 In Visual Studio, this setting allows the Restore NuGet Packages command on the solution's context menu to work. 在Visual Studio中,此设置允许解决方案的上下文菜单上的“还原NuGet软件包”命令起作用。

Appearing to be more to your issue: 似乎更适合您的问题:

Automatically check for missing packages during build in Visual Studio: controls automatic restore by changing the packageRestore/automatic setting in the NuGet.Config file as shown below (%AppData%\\NuGet\\NuGet.Config on Windows, ~/.nuget/NuGet/NuGet.Config on Mac/Linux). 在Visual Studio中的构建过程中自动检查丢失的软件包:通过更改NuGet.Config文件中的packageRestore / automatic设置来控制自动还原,如下所示(在Windows上为%AppData%\\ NuGet \\ NuGet.Config,〜/ .nuget / NuGet / Mac / Linux上的NuGet.Config)。 When this option is set, running a build from Visual Studio automatically restores any missing packages. 设置此选项后,从Visual Studio运行内部版本会自动还原所有丢失的软件包。 The option does not affect builds run from the command line using MSBuild. 该选项不会影响使用MSBuild从命令行运行的生成。

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

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