我已经编写了一个C#代码生成器,用于在Ling- to -SQL应用程序中生成实体和相关的类文件。代码生成器需要在TFS中添加/删除文件,还需要在.csproj文件中添加/删除它们,以便在各自的项目中正确地包含或排除它们。
我已经弄清楚了TFS交互,但对以编程方式在.csproj文件中添加/删除文件的最佳或标准方式感到好奇。有谁有这方面的经验吗?
谢谢-兰迪
发布于 2014-09-04 20:55:40
您创建了一个示例文件,然后引用它可以编辑XML文件的大小写".aspx":{
if ((File.ReadAllText((GlobalVariables.sDestinationPath).Trim() + "" + GlobalVariables.sProjName + "\\" + GlobalVariables.sProjName + projExtention).Contains("<Content Include=\"" + fileName1 + "\" />")) == false)
{
fileReader = File.ReadAllText(GlobalVariables.sDestinationPath + "" + GlobalVariables.sProjName + "\\" + GlobalVariables.sProjName + projExtention + "").Replace("<Content Include=\"Web.config\" />", "<Content Include=\"Web.config\" />" + "\n" + " <Content Include=\"" + fileName1 + "\" />");
File.WriteAllText(GlobalVariables.sDestinationPath.Trim() + "" + GlobalVariables.sProjName + "\\" + GlobalVariables.sProjName + projExtention + "", fileReader);
fileReader = File.ReadAllText(GlobalVariables.sDestinationPath.Trim() + "" + GlobalVariables.sProjName + "\\" + GlobalVariables.sProjName + projExtention + "").Replace("<Compile Include=\"" + pathfol + "\" />", "<Compile Include=\"" + pathfol + "\" />" + "\n" + " <Compile Include=\"" + fileName1 + ".vb\" > " + "\n" + " <DependentUpon>" + fileName1 + "</DependentUpon>" + "\n" + " <SubType>ASPXCodeBehind</SubType>" + "\n" + " </Compile>" + "\n" + " <Compile Include=\"" + fileName1 + ".designer.vb\">" + "\n" + " <DependentUpon>" + fileName1 + "</DependentUpon>" + "\n" + " </Compile> ");
File.WriteAllText(GlobalVariables.sDestinationPath.Trim() + "" + GlobalVariables.sProjName + "\\" + GlobalVariables.sProjName + projExtention + "", fileReader);
}https://stackoverflow.com/questions/2009055
复制相似问题