[英]Modify .NET project files and reference properties
I am developing an application (C#) which would read project properties/references (and properties of the references) from multiple csproj
files, and modify their values. 我正在开发一个应用程序(C#),它将从多个
csproj
文件中读取项目属性/引用(和引用的属性),并修改它们的值。
However, the Reference properties like "copy-local" (the properties you see in the properties explorer when you click on a reference) cannot be found in those csproj
files. 但是,在这些
csproj
文件中找不到像“copy-local”这样的Reference属性(在单击引用时在属性资源管理器中看到的属性)。 Is there a way I can access them and modify their values programatically? 有没有办法可以访问它们并以编程方式修改它们的值?
Everything is in the XML project file - there's not really anywhere else that this information could be, and it has to be somewhere, right? 一切都在XML项目文件中 - 这个信息可能不是其他任何地方,它必须在某个地方,对吧?
Here's an example I've quickly done for you. 这是我很快为你做的一个例子。
Copy Local
is true
by default for framework assemblies. 对于框架程序集,默认情况下
Copy Local
为true
。 When you set Copy Local
to false
, you get an XML element named private
included for that reference which itself is set to false. 当您将
Copy Local
设置为false
,您将获得一个名为private
的XML元素,该元素包含在该引用中,该元素本身设置为false。
In this example System.Core
is set Copy Local
= false
. 在此示例中,
System.Core
设置为Copy Local
= false
。
<Reference Include="System.Core">
<RequiredTargetFramework>3.5</RequiredTargetFramework>
<Private>True</Private>
</Reference>
<Reference Include="System.Web" />
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.