如何通过解析.CSPROJ文件来识别.NET Framework版本 [英] how to identify .NET framework version by parsing .CSPROJ file

查看:223
本文介绍了如何通过解析.CSPROJ文件来识别.NET Framework版本的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

HI

谁能通过解析.CSPROJ文件来帮助我识别.NET Framework版本.
是否有任何指定此版本的垂直标签或属性.
回复

HI

can anyone help me to identify .NET framework version by parsing .CSPROJ file.
Is there any perticular tag or attribute which specifies this version.
reply

推荐答案

只要看一下文件,您就会看到它.
主要标签为TargetFrameworkVersionRequiredTargetFramework.

当然,您可以自己解析文件.选择一种不同的方式:

Just look at the file and you will see it.
Major tags are TargetFrameworkVersion and RequiredTargetFramework.

Of course, you can parse the file by yourself; choose one different ways:


  1. 使用System.Xml.XmlDocument类.它实现了DOM接口;如果文档太大,则这种方法最简单,也足够好.
    请参见
  2. 使用类System.Xml.XmlTextReader; library/system.xml.xmldocument.aspx"target =" _ blank"title =" New Window> ^ ].
  3. 使用类System.Xml.XmlTextReader;这是最快的读取方法,尤其是您需要跳过一些数据.
    请参见 http://msdn.microsoft.com/en-us/library/system.xml.xmlreader.aspx [ http://msdn.microsoft.com/en-us/library/system.xml.xmldocument.aspx [http://msdn.microsoft.com/en-us/library/bb387063.aspx [

  1. Use System.Xml.XmlDocument class. It implements DOM interface; this way is the easiest and good enough if the size if the document is not too big.
    See http://msdn.microsoft.com/en-us/library/system.xml.xmldocument.aspx[^].
  2. Use the class System.Xml.XmlTextReader; this is the fastest way of reading, especially is you need to skip some data.
    See http://msdn.microsoft.com/en-us/library/system.xml.xmlreader.aspx[^].
  3. Use the class System.Xml.Linq.XDocument; this is the most adequate way similar to that of XmlDocument, supporting LINQ to XML Programming.
    See http://msdn.microsoft.com/en-us/library/system.xml.xmldocument.aspx[^], http://msdn.microsoft.com/en-us/library/bb387063.aspx[^].



自然的方法是使用Microsoft.Build.BuildEngineMicrosoft.Build.BuildEngine.Project.

参见:
http://msdn.microsoft.com/en-us/library/microsoft. build.buildengine.engine.aspx [ ^ ],
http://msdn.microsoft.com/en-us/library/microsoft. build.buildengine.project.aspx [ ^ ].

这是从以下代码开始的代码示例:
http://social.msdn.microsoft.com /Forums/zh-CN/msbuild/thread/db705dcf-192c-490e-b34f-7d9546f91e4b/ [



The natural approach would be using Microsoft.Build.BuildEngine and Microsoft.Build.BuildEngine.Project though.

See:
http://msdn.microsoft.com/en-us/library/microsoft.build.buildengine.engine.aspx[^],
http://msdn.microsoft.com/en-us/library/microsoft.build.buildengine.project.aspx[^].

Here is the code sample to start with:
http://social.msdn.microsoft.com/Forums/en-US/msbuild/thread/db705dcf-192c-490e-b34f-7d9546f91e4b/[^].

—SA


右键单击CSPROJ文件并使用记事本打开

在这里您可以看到所有标签.在这里,您可以找到该项目的所有信息.

您可以选择TargetFrameworkVersionOldToolsVersionRequiredTargetFramework作为框架信息.

使用diff技术来解析SAKryukov建议的XML文档.
Right click the CSPROJ file and open with notepad

here you can see all the TAGS. Here you can find out all the information for the project.

You can select TargetFrameworkVersion, OldToolsVersion, RequiredTargetFramework for the framework information.

Use diff techniques to parse the XML document suggested by SAKryukov.


这篇关于如何通过解析.CSPROJ文件来识别.NET Framework版本的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆