pbootcms网站模板|日韩1区2区|织梦模板||网站源码|日韩1区2区|jquery建站特效-html5模板网

是“復(fù)制本地"項目引用的傳遞?

Is quot;Copy Localquot; transitive for project references?(是“復(fù)制本地項目引用的傳遞?)
本文介紹了是“復(fù)制本地"項目引用的傳遞?的處理方法,對大家解決問題具有一定的參考價值,需要的朋友們下面隨著小編來一起學(xué)習(xí)吧!

問題描述

寫.建議的欺騙:因?yàn)檫@里的queston建議與鏈接問題,我寧愿認(rèn)為它不是是騙子.

Wrt. the proposed dupe: Since this here queston suggests the opposite of the linked question, I'd rather like to think it is not a dupe.

首先,我確實(shí)閱讀了 復(fù)制本地"和項目引用的最佳做法是什么?(也 this) 無論如何我都必須嘗試一下,但是獲得對此的一般反饋似乎是必要的,因?yàn)?<關(guān)于這些東西的 rel="noreferrer">docs 太可怕了我只在 VS2010 上,也許他們在較新的版本中改變了一些東西,很高興知道.

First, I did read What is the best practice for "Copy Local" and with project references? (also this) and I'll have to try this out anyway, but getting general feedback on this seems necessary as the docs on this stuff are horrible and I'm only on VS2010 and maybe they changed something in newer versions that'll be nice to know.

第二,我只對這個問題的項目參考感興趣,因?yàn)槲乙呀?jīng) 閱讀來自 GAC 的程序集的處理方式不同,而 GAC 與我的問題無關(guān).

Second, I'm only interested in project references for this question as I've read that assemblies from the GAC are handled differently and the GAC is irrelevant for my problem.

第三,在閱讀了建議的欺騙之后,但更重要的是這里的 answer@Albireo,區(qū)分 file 依賴項似乎也很重要,其中依賴項引用 dll 程序集文件和 project 依賴項(即我要問的),其中依賴項引用了一個項目,并且隱式地引用了該項目的輸出文件.

Third, after reading the suggested dupe, but more so the nice answer here by @Albireo, it would also appear that it is important to differentiate file dependencies, where the dependency references a dll assembly file and project dependencies (i.e. what I'm asking about), where the dependency references a project and implicitly the output file of that project.

  • 2 個 C# 可執(zhí)行項目
  • n C# dll 程序集項目
  • 這 2 個可執(zhí)行文件具有不同的輸出目錄,因?yàn)樗鼈儗为?dú)部署,因此它們在開發(fā)人員計算機(jī)上也是獨(dú)立的
  • 這 2 個可執(zhí)行文件依賴于某些 DLL 程序集(它們可能相互依賴)
  • 共有三個輸出目錄:
    • /x1 用于可執(zhí)行 1 項目
    • /x2 用于可執(zhí)行 2 項目
    • /lib 用于所有 dll 程序集
    • 2 C# executable projects
    • n C# dll assembly projects
    • The 2 executables have different output directories as they will be deployed separately and that way they're also separate on the developer machine
    • The 2 executables have dependencies on some of the DLL assemblies (which may depend on each other)
    • There are three output directories:
      • /x1 for executable 1 project
      • /x2 for executable 2 project
      • /lib for all the dll assemblies

      DLL 程序集allCopy Local設(shè)置為 false 以供其項目引用,因?yàn)樗鼈兌紭?gòu)建到相同的輸出目錄.

      The DLL assemblies all have Copy Localset to false for their project references, as they all build to the same output directory.

      這 2 個可執(zhí)行項目已將它們引用的所有 DLL 程序集項目引用的 Copy Local 設(shè)置為 true直接將DLL復(fù)制到/x1 /x2中.

      The 2 executable projects have set Copy Local to true for all the DLL assembly project references they reference directly, so that the DLLs will be copied into /x1 /x2 respectively.

      問題現(xiàn)在是 wrt.到可執(zhí)行項目直接引用但通過引用的程序集傳遞的DLL:Will程序集,當(dāng)復(fù)制本地"在第一個程序集上設(shè)置為 true 時,通過另一個程序集傳遞引用,復(fù)制到可執(zhí)行文件的輸出文件夾?

      The question now is wrt. to DLLs that are not directly referenced by an executable project, but only transitively through a referenced assembly: Will assemblies, that are only referenced transitively through another assembly, be copied into the output folder of the executable, when "Copy Local" is set to true on the first assembly?

      示例:

      • x1.csproj(例如輸出 = x1/one.exe)
        • 參考:dlA.csproj(例如 Output = lib/a.dll)與 Copy Local = *true*
        • (沒有直接引用 b.dll)
        • x1.csproj (e.g.Output = x1/one.exe)
          • Reference: dlA.csproj ( e.g. Output = lib/a.dll) with Copy Local = *true*
          • (no direct reference on b.dll)
          • 參考:dlB.csproj(例如 Output = lib/b.dll)與 Copy Local = **false**
          • (沒有直接引用 c.dll)
          • Reference: dlB.csproj ( e.g. Output = lib/b.dll) with Copy Local = **false**
          • (no direct reference on c.dll)
          • (沒有進(jìn)一步的相關(guān)參考資料)

          因此,我們有 one.exe -> 的邏輯依賴.a.dll ->b.dll ->c.dll,其中只有a.dll 明顯被復(fù)制到one.exe 的輸出目錄.其他兩個 dll 是否也會被復(fù)制到輸出目錄中? 這是否記錄在某個地方?

          Thus, we have a logical dependency of one.exe -> a.dll -> b.dll -> c.dll, where only a.dll with obviously be copied to the output directory of one.exe. Will the other two dlls also be copied to the output directory? Is this documented somewhere?

          而且,是的,我試過了.而且,是的,它似乎可以工作,但我還沒有足夠努力地戳它,無論如何,我可能錯過了更多的東西.(還有任何官方文檔的問題.)

          And, yes, I tried it. And, yes, it seems to work, but I haven't poked it hard enough yet and anyway there maybe something more to it that I may have missed. (And also there's the question wrt. any official docs.)

          推薦答案

          似乎區(qū)分文件依賴項也很重要,其中依賴項引用 dll 程序集文件和項目依賴項(即我要問的),其中依賴項引用項目并隱含地輸出該項目的文件項目.

          it would also appear that it is important to differentiate file dependencies, where the dependency references a dll assembly file and project dependencies (i.e. what I'm asking about), where the dependency references a project and implicitly the output file of that project.

          不是真的,不.

          MSBuild 并不真正關(guān)心引用是指向解決方案中的另一個項目還是指向 DLL.

          MSBuild doesn't really care if the reference points to another project in the solution or to a DLL.

          如果 ProjectA 依賴 ProjectB 來構(gòu)建 ProjectA ProjectB 必須已經(jīng)構(gòu)建(并且最多日期),然后 MSBuild 將提取其 DLL(而不是其 C# 代碼)并將其鏈接到 ProjectA.

          If ProjectA depends on ProjectB to build ProjectA ProjectB must be already built (and up-to-date), MSBuild will then pull its DLL (not its C# code) and link it to ProjectA.

          添加項目引用而不是 DLL 是語法糖".為了您的方便:這樣 MSBuild 知道它必須選擇引用項目的輸出,無論輸出是什么.

          Adding a project reference instead of a DLL is "syntactic sugar" for your convenience: this way MSBuild knows it must pick the output of the referenced project, whatever the output is.

          否則,您將不得不手動預(yù)構(gòu)建依賴項,找到它的 DLL 并將其鏈接到項目,每當(dāng)您切換構(gòu)建配置、移動或重命名時都重復(fù)該過程.不太實(shí)用.

          Otherwise, you'll have to manually pre-build the dependency, find its DLL and link it to the project, repeating the process whenever you switch build configuration, move or rename things. Not really practical.

          另外兩個dll也會復(fù)制到輸出目錄嗎?

          Will the other two dlls also be copied to the output directory?

          如果直接從引用程序集的項目中使用依賴項中的任何類型的元素,則將復(fù)制該引用.

          If any kind of element from a dependency is used directly from the project where the assembly is referenced, that reference will be copied.

          一個例子可能是這個解決方案布局:

          An example could be this solution layout:

          • 我的解決方案
          • MySolution.ConsoleApplication
          • MySolution.FirstDependency
          • MySolution.SecondDependency
          • MySolution.ThirdDependency
          • MySolution.FourthDependency

          有了這個依賴鏈:

          • MySolution.ConsoleApplication
          • MySolution.FirstDependency
            • MySolution.SecondDependency
              • MySolution.ThirdDependency
              • MySolution.FourthDependency

              如果您構(gòu)建此解決方案,您會注意到在 MySolution.ConsoleApplication 輸出目錄中將有 MySolution.FirstDependencyMySolution.SecondDependency<的 DLL/code> 和 MySolution.ThirdDependency 但沒有 MySolution.FourthDependency 的 DLL.

              If you build this solution you'll notice that in MySolution.ConsoleApplication output directory there will be the DLLs for MySolution.FirstDependency, MySolution.SecondDependency and MySolution.ThirdDependency but no DLL for MySolution.FourthDependency.

              為什么會這樣?當(dāng) MSBuild 構(gòu)建 MySolution.SecondDependency 時,它注意到向 MySolution.FourthDependency 聲明了一個依賴項,但由于它無法從MySolution.FourthDependencyMySolution.SecondDependency 代碼中它決定執(zhí)行一些優(yōu)化";并從輸出中省略 MySolution.FourthDependency 程序集.

              Why is it so? When MSBuild builds MySolution.SecondDependency it notices that there's a dependency declared to MySolution.FourthDependency, but since it can't find any usage of any kind of element from MySolution.FourthDependency in MySolution.SecondDependency code it decides to perform some "optimization" and omits MySolution.FourthDependency assembly from the output.

              過去,當(dāng)我通過 NuGet AutoMapper 添加到深度依賴"時,同樣的問題困擾著我:添加 AutoMapper 會添加兩個程序集引用,AutoMapperAutoMapper.Net4,當(dāng)?shù)诙€程序集需要對 .NET Framework 4 引入的新集合對象執(zhí)行某種操作時,第二個程序集由第一個程序集通過反射加載.由于第二個程序集是通過反射加載的,MSBuild 認(rèn)為它未使用并且沒有懶得到處抄.

              This same issue bit me in the past when I added through NuGet AutoMapper to a "deep dependency": adding AutoMapper adds two assembly references, AutoMapper and AutoMapper.Net4, where the second assembly is loaded by the first through reflection when it needs to perform certain kind of action on the new collection objects introduced by the .NET Framework 4. Since the second assembly is loaded through reflection MSBuild thinks it's unused and doesn't bother to copy it around.

              所以,是的,只要您直接使用它們,它們就會被復(fù)制,而不是通過反射.

              So, yes, they will be copied as long as you're using them directly and not through reflection.

              這是否記錄在某處?

              這種行為似乎是一種特征".在 MSBuild 中,當(dāng)我遇到此問題時,我設(shè)法找到了 Microsoft 一些人的博客文章,但目前我無法再次找到它.

              This behavior seems to be a "feature" of MSBuild, I managed to find a blog post by some folks from Microsoft back when I experienced this issue, but I can't find it again at the moment.

              這篇關(guān)于是“復(fù)制本地"項目引用的傳遞?的文章就介紹到這了,希望我們推薦的答案對大家有所幫助,也希望大家多多支持html5模板網(wǎng)!

              【網(wǎng)站聲明】本站部分內(nèi)容來源于互聯(lián)網(wǎng),旨在幫助大家更快的解決問題,如果有圖片或者內(nèi)容侵犯了您的權(quán)益,請聯(lián)系我們刪除處理,感謝您的支持!

相關(guān)文檔推薦

Is there a way to know if someone has bookmarked your website?(有沒有辦法知道是否有人為您的網(wǎng)站添加了書簽?)
Use of Different .Net Languages?(使用不同的 .Net 語言?)
Is there a C# library that will perform the Excel NORMINV function?(是否有執(zhí)行 Excel NORMINV 函數(shù)的 C# 庫?)
Determining an #39;active#39; user count of an ASP.NET site(確定 ASP.NET 站點(diǎn)的“活動用戶數(shù))
Select x random elements from a weighted list in C# (without replacement)(從 C# 中的加權(quán)列表中選擇 x 個隨機(jī)元素(無需替換))
Best way to keep track of current online users(跟蹤當(dāng)前在線用戶的最佳方式)
主站蜘蛛池模板: 模型公司_模型制作_沙盘模型报价-中国模型网 | 广州昊至泉水上乐园设备有限公司| 岩棉切条机厂家_玻璃棉裁条机_水泥基保温板设备-廊坊鹏恒机械 | 脱硫搅拌器厂家-淄博友胜不锈钢搅拌器厂家 | HV全空气系统_杭州暖通公司—杭州斯培尔冷暖设备有限公司 | 塑木弯曲试验机_铜带拉伸强度试验机_拉压力测试台-倾技百科 | 玉米深加工设备-玉米深加工机械-新型玉米工机械生产厂家-河南粮院机械制造有限公司 | 祝融环境-地源热泵多恒系统高新技术企业,舒适生活环境缔造者! | 四探针电阻率测试仪-振实密度仪-粉末流动性测定仪-宁波瑞柯微智能 | 空气能暖气片,暖气片厂家,山东暖气片,临沂暖气片-临沂永超暖通设备有限公司 | 日本SMC气缸接头-速度控制阀-日本三菱伺服电机-苏州禾力自动化科技有限公司 | 压力控制器,差压控制器,温度控制器,防爆压力控制器,防爆温度控制器,防爆差压控制器-常州天利智能控制股份有限公司 | 坏男孩影院-提供最新电影_动漫_综艺_电视剧_迅雷免费电影最新观看 | 江西高职单独招生-江西单招考试-江西高职单招网 | 亿立分板机_曲线_锯片式_走刀_在线式全自动_铣刀_在线V槽分板机-杭州亿协智能装备有限公司 | 压滤机-洗沙泥浆处理-压泥机-山东创新华一环境工程有限公司 | 下水道疏通_管道疏通_马桶疏通_附近疏通电话- 立刻通 | 铝板冲孔网,不锈钢冲孔网,圆孔冲孔网板,鳄鱼嘴-鱼眼防滑板,盾构走道板-江拓数控冲孔网厂-河北江拓丝网有限公司 | 安规_综合测试仪,电器安全性能综合测试仪,低压母线槽安规综合测试仪-青岛合众电子有限公司 | 铝机箱_铝外壳加工_铝外壳厂家_CNC散热器加工-惠州市铂源五金制品有限公司 | 双段式高压鼓风机-雕刻机用真空泵-绍兴天晨机械有限公司 | 九爱图纸|机械CAD图纸下载交流中心 | 标准品网_标准品信息网_【中检计量】| 水稻烘干机,小麦烘干机,大豆烘干机,玉米烘干机,粮食烘干机_巩义市锦华粮食烘干机械制造有限公司 水环真空泵厂家,2bv真空泵,2be真空泵-淄博真空设备厂 | 镀锌方管,无缝方管,伸缩套管,方矩管_山东重鑫致胜金属制品有限公司 | QQ房产导航-免费收录优秀房地产网站_房地产信息网 | 针焰试验仪,灼热丝试验仪,漏电起痕试验仪,水平垂直燃烧试验仪 - 苏州亚诺天下仪器有限公司 | 储气罐,真空罐,缓冲罐,隔膜气压罐厂家批发价格,空压机储气罐规格型号-上海申容压力容器集团有限公司 | 学生作文网_中小学生作文大全与写作指导| 一点车讯-汽车网站,每天一点最新车讯! | 福建自考_福建自学考试网 | PU树脂_水性聚氨酯树脂_聚氨酯固化剂_聚氨酯树脂厂家_宝景化工 | 航空铝型材,7系铝型材挤压,硬质阳*氧化-余润铝制品 | 阿米巴企业经营-阿米巴咨询管理-阿米巴企业培训-广东键锋企业管理咨询有限公司 | 沈阳液压泵_沈阳液压阀_沈阳液压站-沈阳海德太科液压设备有限公司 | 常州律师事务所_常州律所_常州律师-江苏乐天律师事务所 | 龙门加工中心-数控龙门加工中心厂家价格-山东海特数控机床有限公司_龙门加工中心-数控龙门加工中心厂家价格-山东海特数控机床有限公司 | 深圳市八百通智能技术有限公司官方网站 | 东莞画册设计_logo/vi设计_品牌包装设计 - 华略品牌设计公司 | 北京康百特科技有限公司-分子蒸馏-短程分子蒸馏设备-实验室分子蒸馏设备 | 锡膏喷印机-全自动涂覆机厂家-全自动点胶机-视觉点胶机-深圳市博明智控科技有限公司 |