I am wondering if there are any heuristics for when to set copy-local=true
for references?
我想知道在什么时候为引用设置copy-local=true是否存在启发式?
If referenced types are only used internally can I set copy-local
to true
but if referenced types are exposed as parameters or return values I set copy-local
to false
and indicate that a specific version of the dependency should be referenced when my library should be used?
如果引用类型只在内部使用,我可以将copy-local设置为true,但如果引用类型作为参数或返回值公开,我将copy-local设置为false,并表明在使用我的库时应该引用依赖项的特定版本?
Can anyone clarify this for me?
有人能帮我澄清一下吗?
7 个解决方案
#1
45
Copy local is important for deployment scenarios and tools. As a general rule you should use CopyLocal=True if the reference is not contained within the GAC.
复制本地对于部署场景和工具非常重要。一般来说,如果引用不包含在GAC中,应该使用CopyLocal=True。
Copy Local essentially means I must manually deploy this DLL in order for my application to work. When it's false it essentially means "I depend on another component which must be installed separately or chained, the DLL will just be there already".
复制本地本质上意味着我必须手动部署这个DLL以便我的应用程序工作。当它为false时,它的本质意思是“我依赖另一个必须单独安装或链接的组件,DLL将已经存在”。
#2
14
Copy local was implemented really to support local debugging. When you perpare your application for package and deployment you should build your projects to the same output folder and make sure you have all the references you need there.
Copy local实际上是为了支持本地调试而实现的。当您仔细检查应用程序的包和部署时,您应该将项目构建到相同的输出文件夹中,并确保您拥有那里需要的所有引用。
CopyLocal is especially a pain when building large source trees. There was a related question about how to disable CopyLocal here on SO you can see it at How do I override CopyLocal (Private) setting for references in .NET from MSBUILD. As well as Best practices for large solutions in Visual Studio (2008).
CopyLocal在构建大型源树时特别麻烦。这里有一个相关的问题,关于如何禁用CopyLocal,以便您可以在如何覆盖。net中来自MSBUILD的引用的CopyLocal (Private)设置时看到它。以及Visual Studio(2008)中的大型解决方案的最佳实践。
I have written about how to deal with building large source trees in the article MSBuild: Best Practices For Creating Reliable Builds, Part 2.
在第2部分MSBuild:创建可靠构建的最佳实践中,我已经写了关于如何处理构建大型源树的文章。
So in short I would say disable CopyLocal when the file copying is causing your builds to take more time then you are willing to spend for every build.
简而言之,当文件复制导致你的构建花费更多的时间时,我想说的是禁用CopyLocal,这样你就愿意为每一个构建花费时间。
#3
11
It's really about the target environment. If copy local is false, you're saying that the assembly will already exist in the target environment (normally in the GAC). Setting it to true ensures it will appear in the output of your build, so makes it easier to deploy to the target environment.
这是关于目标环境的。如果copy local为false,则表示程序集已经存在于目标环境中(通常在GAC中)。将其设置为true可以确保它将出现在您的构建的输出中,因此更容易部署到目标环境。
#4
6
Check out the following MSDN reference which explains CopyLocal behavior in detail.
请查看下面的MSDN引用,它详细解释了CopyLocal行为。
项目引用
Unfortunately there are some quirks and CopyLocal won't necessary work as expected for assembly references in secondary assemblies structured as shown below.
不幸的是,有一些怪怪的和CopyLocal不需要像预期的那样在二级程序集中的装配引用中工作,如下所示。
- MainApp.exe
- MyLibrary.dll
- ThirdPartyLibrary.dll (if in the GAC CopyLocal won't copy to MainApp bin folder)
- ThirdPartyLibrary。dll(如果在GAC CopyLocal中不会复制到MainApp bin文件夹)
- MyLibrary。dll ThirdPartyLibrary。dll(如果在GAC CopyLocal中不会复制到MainApp bin文件夹)
- MyLibrary.dll
- MainApp。exe MyLibrary。dll ThirdPartyLibrary。dll(如果在GAC CopyLocal中不会复制到MainApp bin文件夹)
This makes xcopy deployments difficult if you don't plan on installing the third party assembly into the GAC on the target machine.
如果您不打算在目标机器上将第三方程序集安装到GAC中,这将使xcopy部署变得困难。
#5
2
This option only affects build phase. It just copies the reference to local directory of the built assembly.
此选项只影响构建阶段。它只是将引用复制到构建程序集的本地目录。
If another assembly (T) wants to use a method from the assembly you are building (A) which has return type or parameters from another referenced assembly (R), it (T) should be able to access that assembly (R). It might be able to do so without doing anything special if the referenced assembly (R) is installed in GAC. Otherwise, it needs a local copy of that.
如果另一个组件(T)希望利用装配您正在构建的方法(a)从另一个返回类型或参数的引用组装(R),它(T)应该能够访问该组装(R)。这样做也许可以不需要做任何特殊的配置如果引用的组装(R)是安装在广汽。否则,它需要一个本地副本。
#6
0
Set CopyLocal=false will improve build time, but can cause different issues during deployment time.
设置CopyLocal=false将改进构建时间,但是在部署期间会导致不同的问题。
My experience with setting CopyLocal=false wasn't successfull. See summary of pro and cons in my blog post "Do NOT Change "Copy Local” project references to false, unless understand subsequences."
我设置CopyLocal=false的经验没有成功。请参阅我的博客文章“不要将“复制本地”项目引用更改为false,除非理解子序列。”
#7
0
Conservative way to set CopyLocal false is to check that the reference is found in the output path of the project. This should allow you to dodge some nasty runtime issues, while still reducing the amount of IO.
设置CopyLocal false的保守方法是检查在项目的输出路径中是否找到了引用。这将使您能够避免一些严重的运行时问题,同时仍然减少IO的数量。
In the process I created CopyLocalFixer, which you can run for a folder. I tried this with one large build, but the results weren't that impressive to be honest. I guess it comes down to the folder structure of the project.
在这个过程中,我创建了CopyLocalFixer,您可以为一个文件夹运行它。我尝试了一个大的构建,但是结果并不令人印象深刻。我想应该是项目的文件夹结构。
#1
45
Copy local is important for deployment scenarios and tools. As a general rule you should use CopyLocal=True if the reference is not contained within the GAC.
复制本地对于部署场景和工具非常重要。一般来说,如果引用不包含在GAC中,应该使用CopyLocal=True。
Copy Local essentially means I must manually deploy this DLL in order for my application to work. When it's false it essentially means "I depend on another component which must be installed separately or chained, the DLL will just be there already".
复制本地本质上意味着我必须手动部署这个DLL以便我的应用程序工作。当它为false时,它的本质意思是“我依赖另一个必须单独安装或链接的组件,DLL将已经存在”。
#2
14
Copy local was implemented really to support local debugging. When you perpare your application for package and deployment you should build your projects to the same output folder and make sure you have all the references you need there.
Copy local实际上是为了支持本地调试而实现的。当您仔细检查应用程序的包和部署时,您应该将项目构建到相同的输出文件夹中,并确保您拥有那里需要的所有引用。
CopyLocal is especially a pain when building large source trees. There was a related question about how to disable CopyLocal here on SO you can see it at How do I override CopyLocal (Private) setting for references in .NET from MSBUILD. As well as Best practices for large solutions in Visual Studio (2008).
CopyLocal在构建大型源树时特别麻烦。这里有一个相关的问题,关于如何禁用CopyLocal,以便您可以在如何覆盖。net中来自MSBUILD的引用的CopyLocal (Private)设置时看到它。以及Visual Studio(2008)中的大型解决方案的最佳实践。
I have written about how to deal with building large source trees in the article MSBuild: Best Practices For Creating Reliable Builds, Part 2.
在第2部分MSBuild:创建可靠构建的最佳实践中,我已经写了关于如何处理构建大型源树的文章。
So in short I would say disable CopyLocal when the file copying is causing your builds to take more time then you are willing to spend for every build.
简而言之,当文件复制导致你的构建花费更多的时间时,我想说的是禁用CopyLocal,这样你就愿意为每一个构建花费时间。
#3
11
It's really about the target environment. If copy local is false, you're saying that the assembly will already exist in the target environment (normally in the GAC). Setting it to true ensures it will appear in the output of your build, so makes it easier to deploy to the target environment.
这是关于目标环境的。如果copy local为false,则表示程序集已经存在于目标环境中(通常在GAC中)。将其设置为true可以确保它将出现在您的构建的输出中,因此更容易部署到目标环境。
#4
6
Check out the following MSDN reference which explains CopyLocal behavior in detail.
请查看下面的MSDN引用,它详细解释了CopyLocal行为。
项目引用
Unfortunately there are some quirks and CopyLocal won't necessary work as expected for assembly references in secondary assemblies structured as shown below.
不幸的是,有一些怪怪的和CopyLocal不需要像预期的那样在二级程序集中的装配引用中工作,如下所示。
- MainApp.exe
- MyLibrary.dll
- ThirdPartyLibrary.dll (if in the GAC CopyLocal won't copy to MainApp bin folder)
- ThirdPartyLibrary。dll(如果在GAC CopyLocal中不会复制到MainApp bin文件夹)
- MyLibrary。dll ThirdPartyLibrary。dll(如果在GAC CopyLocal中不会复制到MainApp bin文件夹)
- MyLibrary.dll
- MainApp。exe MyLibrary。dll ThirdPartyLibrary。dll(如果在GAC CopyLocal中不会复制到MainApp bin文件夹)
This makes xcopy deployments difficult if you don't plan on installing the third party assembly into the GAC on the target machine.
如果您不打算在目标机器上将第三方程序集安装到GAC中,这将使xcopy部署变得困难。
#5
2
This option only affects build phase. It just copies the reference to local directory of the built assembly.
此选项只影响构建阶段。它只是将引用复制到构建程序集的本地目录。
If another assembly (T) wants to use a method from the assembly you are building (A) which has return type or parameters from another referenced assembly (R), it (T) should be able to access that assembly (R). It might be able to do so without doing anything special if the referenced assembly (R) is installed in GAC. Otherwise, it needs a local copy of that.
如果另一个组件(T)希望利用装配您正在构建的方法(a)从另一个返回类型或参数的引用组装(R),它(T)应该能够访问该组装(R)。这样做也许可以不需要做任何特殊的配置如果引用的组装(R)是安装在广汽。否则,它需要一个本地副本。
#6
0
Set CopyLocal=false will improve build time, but can cause different issues during deployment time.
设置CopyLocal=false将改进构建时间,但是在部署期间会导致不同的问题。
My experience with setting CopyLocal=false wasn't successfull. See summary of pro and cons in my blog post "Do NOT Change "Copy Local” project references to false, unless understand subsequences."
我设置CopyLocal=false的经验没有成功。请参阅我的博客文章“不要将“复制本地”项目引用更改为false,除非理解子序列。”
#7
0
Conservative way to set CopyLocal false is to check that the reference is found in the output path of the project. This should allow you to dodge some nasty runtime issues, while still reducing the amount of IO.
设置CopyLocal false的保守方法是检查在项目的输出路径中是否找到了引用。这将使您能够避免一些严重的运行时问题,同时仍然减少IO的数量。
In the process I created CopyLocalFixer, which you can run for a folder. I tried this with one large build, but the results weren't that impressive to be honest. I guess it comes down to the folder structure of the project.
在这个过程中,我创建了CopyLocalFixer,您可以为一个文件夹运行它。我尝试了一个大的构建,但是结果并不令人印象深刻。我想应该是项目的文件夹结构。