I need to force all of my projects to use dll's
that are stored in a common location. I am starting by refactoring existing projects to point to the dll's
source folder of my preference. So I decided to try a programmatic way for changing these references.
I read dll
references as following:
XNamespace msbuild = "http://schemas.microsoft.com/developer/msbuild/2003";
XDocument projDefinition = XDocument.Load(filePath);
IEnumerable<string> references = projDefinition
.Element(msbuild + "Project")
.Elements(msbuild + "ItemGroup")
.Elements(msbuild + "Reference")
.Elements(msbuild + "HintPath")
.Select(refElem => refElem.Value);
The next step is to change reference HintPath
based on reference name. I plan on creating a dictionary of references and then run through them to update each of the project files.
However, I cannot find any solid way of reading and changing HintPath
based on Reference
inside csproj
.