如何阻止 Visual Studio 复制次要参考文献?
How to stop Visual Studio from copying secondary references?
我是 运行 Visual Studio 2015.
我有一个实用程序库项目,它引用了许多第三方程序集,这些程序集都在 GAC 中注册。在该项目中,在 GAC 中注册的所有依赖项都是将复制本地设置为 false 的引用。当我构建该项目时,GAC 程序集未复制到构建目录。
实用程序项目随后作为一个项目被另一个项目引用,“复制本地”设置为 true。然后引用项目生成,实用程序项目引用的所有 GAC 程序集都复制到生成目录。这些程序集非常大,它确实会减慢构建速度并使构建目录膨胀。
Visual Studio2013年没做这个。未复制在 GAC 中注册的二级参考文献。我还应该注意,在 Visual Studio 2015 年,如果我将实用程序项目作为文件而不是项目来引用,那么辅助引用也会被复制。有没有办法阻止它复制次要依赖项?
以下是 MSBuild 的详细输出部分,用于复制的次要引用之一:
4> Dependency "ESRI.ArcGIS.Catalog, Version=10.5.0.0, Culture=neutral, PublicKeyToken=8fc3cc631e44ad86".
4> Resolved file path is "C:\Program Files (x86)\ArcGIS\DeveloperKit10.5\DotNet\ESRI.ArcGIS.Catalog.dll".
4> Reference found at search path location "{Registry:Software\Microsoft\.NETFramework,v4.7.2,AssemblyFoldersEx}".
4> For SearchPath "C:\...\bin\Release".
4> Considered "C:\...\bin\Release\ESRI.ArcGIS.Catalog.winmd", but it didn't exist.
4> Considered "C:\...\bin\Release\ESRI.ArcGIS.Catalog.dll", but it didn't exist.
4> Considered "C:\...\bin\Release\ESRI.ArcGIS.Catalog.exe", but it didn't exist.
4> For SearchPath "{TargetFrameworkDirectory}".
4> Considered "C:\Program Files (x86)\Reference Assemblies\Microsoft\Framework\.NETFramework\v4.7.2\ESRI.ArcGIS.Catalog.winmd", but it didn't exist.
4> Considered "C:\Program Files (x86)\Reference Assemblies\Microsoft\Framework\.NETFramework\v4.7.2\ESRI.ArcGIS.Catalog.dll", but it didn't exist.
4> Considered "C:\Program Files (x86)\Reference Assemblies\Microsoft\Framework\.NETFramework\v4.7.2\ESRI.ArcGIS.Catalog.exe", but it didn't exist.
4> Considered "C:\Program Files (x86)\Reference Assemblies\Microsoft\Framework\.NETFramework\v4.7.2\Facades\ESRI.ArcGIS.Catalog.winmd", but it didn't exist.
4> Considered "C:\Program Files (x86)\Reference Assemblies\Microsoft\Framework\.NETFramework\v4.7.2\Facades\ESRI.ArcGIS.Catalog.dll", but it didn't exist.
4> Considered "C:\Program Files (x86)\Reference Assemblies\Microsoft\Framework\.NETFramework\v4.7.2\Facades\ESRI.ArcGIS.Catalog.exe", but it didn't exist.
4> For SearchPath "{Registry:Software\Microsoft\.NETFramework,v4.7.2,AssemblyFoldersEx}".
4> Considered AssemblyFoldersEx locations.
4> Required by "C:\...\bin\Release\ArcBase.dll".
4> Found related file "C:\Program Files (x86)\ArcGIS\DeveloperKit10.5\DotNet\ESRI.ArcGIS.Catalog.xml".
4> The ImageRuntimeVersion for this reference is "v4.0.30319".
How to stop Visual Studio from copying secondary references?
AFAIK,Copy Local = False
本身应该足以防止那些第三方程序集被复制到另一个项目构建目录。这反过来会阻止 msbuild 在构建另一个项目时找到这些 GAC 程序集。它根本不应该寻找它,因为 GAC 程序集不应再出现在另一个项目的清单中。这里不止一件事出了问题。要跟踪此问题,您应该将 MSBuild 输出日志更改为 Detailed 以了解它是如何设法找到它的。
将 MSBuild 更改为详细:
在Tools
–>Options
–>Projects and Solutions
–>Build and Run
->MSBuild project build output verbosity
下,将MSBuild项目build output verbosity改为详细或诊断。
此外,作为解决方法,您可以将这些第三方程序集设置为nuget包,而不是将它们设置到GAC中,然后将此nuget包添加到另一个项目中,构建项目,那些第三方程序集不会复制到另一个项目的bin文件夹中。
希望对您有所帮助。
我最终确实解决了这个问题。解决方案是将此部分添加到辅助库项目的 .csproj 文件中:
<Project... >
<PropertyGroup>
<DoNotCopyLocalIfInGac>true</DoNotCopyLocalIfInGac>
</PropertyGroup>
我是 运行 Visual Studio 2015.
我有一个实用程序库项目,它引用了许多第三方程序集,这些程序集都在 GAC 中注册。在该项目中,在 GAC 中注册的所有依赖项都是将复制本地设置为 false 的引用。当我构建该项目时,GAC 程序集未复制到构建目录。
实用程序项目随后作为一个项目被另一个项目引用,“复制本地”设置为 true。然后引用项目生成,实用程序项目引用的所有 GAC 程序集都复制到生成目录。这些程序集非常大,它确实会减慢构建速度并使构建目录膨胀。
Visual Studio2013年没做这个。未复制在 GAC 中注册的二级参考文献。我还应该注意,在 Visual Studio 2015 年,如果我将实用程序项目作为文件而不是项目来引用,那么辅助引用也会被复制。有没有办法阻止它复制次要依赖项?
以下是 MSBuild 的详细输出部分,用于复制的次要引用之一:
4> Dependency "ESRI.ArcGIS.Catalog, Version=10.5.0.0, Culture=neutral, PublicKeyToken=8fc3cc631e44ad86".
4> Resolved file path is "C:\Program Files (x86)\ArcGIS\DeveloperKit10.5\DotNet\ESRI.ArcGIS.Catalog.dll".
4> Reference found at search path location "{Registry:Software\Microsoft\.NETFramework,v4.7.2,AssemblyFoldersEx}".
4> For SearchPath "C:\...\bin\Release".
4> Considered "C:\...\bin\Release\ESRI.ArcGIS.Catalog.winmd", but it didn't exist.
4> Considered "C:\...\bin\Release\ESRI.ArcGIS.Catalog.dll", but it didn't exist.
4> Considered "C:\...\bin\Release\ESRI.ArcGIS.Catalog.exe", but it didn't exist.
4> For SearchPath "{TargetFrameworkDirectory}".
4> Considered "C:\Program Files (x86)\Reference Assemblies\Microsoft\Framework\.NETFramework\v4.7.2\ESRI.ArcGIS.Catalog.winmd", but it didn't exist.
4> Considered "C:\Program Files (x86)\Reference Assemblies\Microsoft\Framework\.NETFramework\v4.7.2\ESRI.ArcGIS.Catalog.dll", but it didn't exist.
4> Considered "C:\Program Files (x86)\Reference Assemblies\Microsoft\Framework\.NETFramework\v4.7.2\ESRI.ArcGIS.Catalog.exe", but it didn't exist.
4> Considered "C:\Program Files (x86)\Reference Assemblies\Microsoft\Framework\.NETFramework\v4.7.2\Facades\ESRI.ArcGIS.Catalog.winmd", but it didn't exist.
4> Considered "C:\Program Files (x86)\Reference Assemblies\Microsoft\Framework\.NETFramework\v4.7.2\Facades\ESRI.ArcGIS.Catalog.dll", but it didn't exist.
4> Considered "C:\Program Files (x86)\Reference Assemblies\Microsoft\Framework\.NETFramework\v4.7.2\Facades\ESRI.ArcGIS.Catalog.exe", but it didn't exist.
4> For SearchPath "{Registry:Software\Microsoft\.NETFramework,v4.7.2,AssemblyFoldersEx}".
4> Considered AssemblyFoldersEx locations.
4> Required by "C:\...\bin\Release\ArcBase.dll".
4> Found related file "C:\Program Files (x86)\ArcGIS\DeveloperKit10.5\DotNet\ESRI.ArcGIS.Catalog.xml".
4> The ImageRuntimeVersion for this reference is "v4.0.30319".
How to stop Visual Studio from copying secondary references?
AFAIK,Copy Local = False
本身应该足以防止那些第三方程序集被复制到另一个项目构建目录。这反过来会阻止 msbuild 在构建另一个项目时找到这些 GAC 程序集。它根本不应该寻找它,因为 GAC 程序集不应再出现在另一个项目的清单中。这里不止一件事出了问题。要跟踪此问题,您应该将 MSBuild 输出日志更改为 Detailed 以了解它是如何设法找到它的。
将 MSBuild 更改为详细:
在Tools
–>Options
–>Projects and Solutions
–>Build and Run
->MSBuild project build output verbosity
下,将MSBuild项目build output verbosity改为详细或诊断。
此外,作为解决方法,您可以将这些第三方程序集设置为nuget包,而不是将它们设置到GAC中,然后将此nuget包添加到另一个项目中,构建项目,那些第三方程序集不会复制到另一个项目的bin文件夹中。
希望对您有所帮助。
我最终确实解决了这个问题。解决方案是将此部分添加到辅助库项目的 .csproj 文件中:
<Project... >
<PropertyGroup>
<DoNotCopyLocalIfInGac>true</DoNotCopyLocalIfInGac>
</PropertyGroup>