开发者

Assembly name from MSBUILD

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 the Compile group). It sounds like you want to be poking around in the project's PropertyGroups collection.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜