問題描述
我已經(jīng)為此苦苦掙扎了幾天,經(jīng)過大量搜索后,我找不到我應(yīng)該走的路.
I have been wrestling with this for a few days and after tons of searching I can't find the path I should be on.
我想要做的是設(shè)置一個 MSBUILD 項目,它將構(gòu)建我們的整個 .NET 應(yīng)用程序(8 個解決方案的常量,并且可能有 250 個項目在它們之間拆分),其中一些設(shè)置從單個項目文件中覆蓋以進行自己的調(diào)試版本.
What I want to do is set up an MSBUILD project that will build our entire .NET application (constst of 8 solutions, and maybe 250 projects split up between them) with a number of settings overridden from the individual project files to make a debug build for myself.
具體來說,我想構(gòu)建我們的發(fā)布配置,關(guān)閉優(yōu)化并生成完整的調(diào)試信息/pdb.另外,為了減少我們目前超長的構(gòu)建時間,我希望每個項目的每個引用都復(fù)制本地"(或?qū)嶋H項目文件 xml 中的私有)為 false.
Specifically I want to build our release configuration with optimizations off and full debug info / pdbs generated. Also, in order to reduce our currently ultra-long build time I want "copy local" (or private in the actual proj file xml) false for every reference of every project.
第一件事很簡單,我可以很容易地覆蓋項目級別的屬性(您甚至可以使用/p 從 MSBuild 命令行執(zhí)行此操作),但我不知道如何覆蓋一個參考.我已經(jīng)嘗試了一些我在 StackOverflow 和網(wǎng)絡(luò)上看到的東西,但還沒有一個解決方案.
The first things were fairly easy, I can override a project level property fairly easily (you can even do this from the MSBuild command line using /p), but what I can't figure out is how to override a property on a reference. I have tried several things I saw here on StackOverflow and around the web, but nothing is a solution yet.
我可以通過更改 Microsoft.Common.targets 來做我想做的事,注釋掉 _CopyFilesMarkedCopyLocal 目標中的代碼會完全跳過這些文件的復(fù)制.但我不想改變我的全局配置并在所有情況下都這樣做.我創(chuàng)建了自己的備用目標文件——如果我改變一個單獨的項目文件以指向它,它就可以工作——但我不知道如何指定它在頂層使用(我的 .proj 文件只是構(gòu)建所有 8 個解決方案).如果我能以某種方式僅覆蓋頂層的 _CopyFilesMarkedCopyLocal 目標,那就太好了,這樣如果 MS 更改了默認目標文件,我的構(gòu)建就不會搞砸,但我也不知道如何使它工作.
I can do what I want by altering Microsoft.Common.targets, commenting out the code in the _CopyFilesMarkedCopyLocal target completely skips the copying of these files. But I don't want to alter my global configuration and do this in all circumstances. I created my own alternate targets file -- which works if I alter an individual project file to point to it -- but I can't figure out how to specify this to be used at the top level (my .proj file that just builds all 8 solutions). It would be great if I could somehow override just the _CopyFilesMarkedCopyLocal target at the top level so that if MS changes the default targets file my build isn't screwed up, but I can't figure out how to make this work either.
如果有一種方法可以覆蓋參考級別屬性,就像您可以項目級別屬性一樣,而不必重寫/覆蓋構(gòu)建目標的東西,那么最好的可能就是 - 但我沒有發(fā)現(xiàn)任何信息表明這是可能的.
The best possible thing would be if there was a way to just override reference level properties like you can project level properties, without having to rewrite/override the build targets stuff -- but I have found no information indicating this is possible.
提前感謝您對此提供的任何幫助.
Thanks in advance for any help on this.
附言我實際上不可能瀏覽所有項目文件并更改它們;我需要一個解決方案,讓現(xiàn)有代碼保持原樣.
P.S. It is not possible for me to actually just go through all the projects files and change them; I need a solution that leaves the existing code in place as is.
推薦答案
試試這個:
將 CustomAfterMicrosoftCommonTargets 設(shè)置為 C:foofilter.targets (或任何您命名的文件) 并將 filter.targets 設(shè)置為:
Set the CustomAfterMicrosoftCommonTargets to C:foofilter.targets (or whatever you name the file) and have filter.targets to be:
<Project xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<ItemDefinitionGroup>
<Reference>
<Private>False</Private>
</Reference>
</ItemDefinitionGroup>
</Project>
這篇關(guān)于如何從 MSBUILD 覆蓋 .NET 中引用的 CopyLocal(私有)設(shè)置的文章就介紹到這了,希望我們推薦的答案對大家有所幫助,也希望大家多多支持html5模板網(wǎng)!