aromore
aromore

Reputation: 1077

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?

Upvotes: 4

Views: 5968

Answers (1)

Kirk Broadhurst
Kirk Broadhurst

Reputation: 28738

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" />

Upvotes: 8

Related Questions