c#包含类文件到csprj中
public ActionResult Index()
{ XDocument doc = XDocument.Load(@"G:\users\kim.gao\documents\visual studio 2015\Projects\test\test\test.csproj");
ContainFileToCsproj(@"T4\AccountViewModels.cs", "", "", doc);
doc.Save(@"G:\users\kim.gao\documents\visual studio 2015\Projects\test\test\test.csproj");
return View();
}
public static void ContainFileToCsproj(string fileName, string solutionDir, string csprojName, XDocument doc)
{
string path = @"G:\users\kim.gao\documents\visual studio 2015\Projects\test\test\test.csproj";
XElement root = doc.Root;
string xmlns = "{" + root.Attribute("xmlns").Value + "}";
IEnumerable<XElement> compileList = root.Elements(xmlns + "ItemGroup").Elements(xmlns + "Compile");
XElement itemGroup = compileList.FirstOrDefault().Parent;
if (compileList.Where(u => u.Attribute("Include").Value == fileName).Count() > )
{
compileList.Where(u => u.Attribute("Include").Value == fileName).Remove();
} XElement compile = new XElement(xmlns + "Compile");
compile.SetAttributeValue("Include", fileName);
itemGroup.AddFirst(compile);
}
c#包含类文件到csprj中的更多相关文章
- include包含头文件的语句中,双引号和尖括号的区别是什么?
include包含头文件的语句中,双引号和尖括号的区别是什么? #include <> 格式:引用标准库头文件,编译器从标准库目录开始搜索 尖括号表示只在系统默认目录或者括号内的路径查找 ...
- include包含头文件的语句中,双引号和尖括号的区别
include包含头文件的语句中,双引号和尖括号的区别 #include <>格式:引用标准库头文件,编译器从标准库目录开始搜索 #incluce ""格式:引用非 ...
- php自动加载类文件探讨,spl_autoload_register自动加载原理
spl_autoload_register函数是实现自动加载未定义类功能的的重要方法,所谓的自动加载意思就是 我们的new 一个类的时候必须先include或者require的类文件,如果没有incl ...
- VS App_Code文件夹下的类文件不能直接被调用的解决方法
如下图所示,新建的类不能直接使用,会显示报错,检查命名空间什么的,未果 通过百度搜索,发现这么一篇文章:https://blog.csdn.net/younghaiqing/article/detai ...
- Eclipse插件开发中对于Jar包和类文件引用的处理(彻底解决插件开发中的NoClassDefFoundError问题)(转)
目的:Eclipse插件开发中,经常要引用第三方包或者是引用其他插件中的类,由于插件开发环境引用类路径的设置和运行平台引用类路径的设置不同,经常导致开发过程OK,一旦运行则出现NoClassDefFo ...
- Xamarin.Froms项目中包含的文件
Clearly, the program created by the Xamarin.Forms template is very simple, so this is an excellent o ...
- spring boot 启动类一定要放置到包的根目录下,也就是和所有包含java文件的包在同一级目录。如果不放置在根目录下,将会提示 no mybatis mapper was found
spring boot 启动类一定要放置到包的根目录下,也就是和所有包含java文件的包在同一级目录.将会将同一目录下的包扫描成bean. 如果不放置在根目录下,将会提示 no mybatis map ...
- 用字符流实现每个文件夹中创建包含所有文件信息的readme.txt
package com.readme; import java.io.BufferedWriter; import java.io.File; import java.io.FileWriter; i ...
- Swift: 在Swift中桥接OC文件(自己创建的类文件、第三方库文件)
一.介绍 随着Swift的逐渐成熟,使用swift开发或者混合开发已经成为了一个趋势,本身苹果公司也十分推荐使用Swift这门新语言.目前Swift已经更新到了3.0,估计没有多久4.0就要出来了.那 ...
随机推荐
- frame自适应
<html> <head> <title>frame自适应</title> </head> <frameset rows=" ...
- 使用 "java -jar"命令启动jar包时报不支持的jdk版本异常
在使用java -jar 命令启动一个jar包的时候,提示版本不支持: [root@hadoop01 eureka-server-master]# java -jar xuebusi-eureka-s ...
- 【转】Android的root原理
转自知乎:https://www.zhihu.com/question/21074979 @Kevin @张炬 作者:Kevin链接:https://www.zhihu.com/question/21 ...
- whatweb wordpress.rb
## # This file is part of WhatWeb and may be subject to # redistribution and commercial restrictions ...
- 基于jquery横向手风琴效果
基于jquery横向手风琴效果是一款基于jquery实现的左右滑动手风琴图片轮播切换特效.效果图如下: 在线预览 源码下载 效果图如下: <div class="flash&quo ...
- Android 底部按钮BottomNavigationView + Fragment 的使用(二)
这里来试验BottomNavigationView + Fragment 底部按钮通过点击底部选项,实现中间的Fragment进行页面的切换. 使用BottomNavigationView 控件,实现 ...
- ython strip lstrip rstrip使用方法
Python中的strip用于去除字符串的首尾字符,同理,lstrip用于去除左边的字符,rstrip用于去除右边的字符. 这三个函数都可传入一个参数,指定要去除的首尾字符. 需要注意的是,传入的是一 ...
- putty配色备份
[HKEY_CURRENT_USER\Software\SimonTatham\PuTTY\Sessions\Solarized%20Dark] "Colour0"="1 ...
- u-boot的配置
1 sama5d31dk sama5d3_xplained:SAMA5D3,SYS_USE_NANDFLASH ...
- 临时文件夹迁移 temp位置移动
方法/步骤 首先,在其他驱动器新建一个文件夹,给临时文件夹安个新家 桌面,右键"我的电脑",选择"属性" 点击"高级系统设置" 点击&quo ...