I am developing an app that reads a MSBUILD file ( *.csproj ) to pull out various bits of information. A previous question on here revealed that I can get the resource files being used in the following manner
Project project = new Project();
project.Load(fullPathName);
var embeddedResources =
from grp in project.ItemGroups.Cast<BuildItemGroup>()
from item in grp.Cast<BuildItem>()
where item.Name == "EmbeddedResource"
select item;
Now I want to get the assembly name for the project. My initial to look in the "BuildProperyGroup" for a "BuildProperty" with "Name = 'AssemblyName"
I fell at the first hurdle
var test =
from grp in project.ItemGroups.Cast<BuildProperyGroup>()
fails with an invalid cast.
Any clues as to where I am going wrong..
The solution I ended up with is as follows
var PropG =
from pg in project.PropertyGroups.Cast<BuildPropertyGroup>()
from item in pg.Cast<BuildProperty>()
where item.Name == "AssemblyName"
select item.Value.ToString();
ItemsGroups are for collections of files, generally (such as all the
.cs
files in theCompile
group). It sounds like you want to be poking around in the project's PropertyGroups collection.