简体   繁体   中英

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.

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. 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?

Here's an example I've quickly done for you. Copy Local is true by default for framework assemblies. When you set Copy Local to false , you get an XML element named private included for that reference which itself is set to false.

In this example System.Core is set Copy Local = false .

<Reference Include="System.Core">
  <RequiredTargetFramework>3.5</RequiredTargetFramework>
  <Private>True</Private>
</Reference>
<Reference Include="System.Web" />

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM