如何动态地向构建(.csproj)文件添加文件



当客户创建一个新的工作空间时,我生成了一堆文件,我想将它们添加到现有的项目文件中,最好的方法是什么?

标准:它需要在visual studio中工作,并且需要在独立构建中工作

// get the project file ...
var projectfile = Directory.GetFiles(Requested.Workspace.AppRoot, "*.csproj", SearchOption.AllDirectories).Single();
var project = new Project(projectfile);
// add generated items ...
foreach (var item in Requested.Manifest.Items)
{
   project.Items.Add(new ProjectItem(item.Info.FullName,"??"));
}
if (!project.Build())
{
   Console.ReadLine();
}

帮助任何人吗?

您可以创建一个.cs文件,并将所有填充内容作为方法明智地添加到其中,并根据工作区调用特定的函数。

If(workspace 1)
{
// call file1Method()
}

其他

最新更新