[英]Using Roslyn (Microsoft.CodeAnalysis) to query information of WebSite projects
I'm trying to implement a tool for static code analysis using Roslyn. 我正在尝试使用罗斯林实现用于静态代码分析的工具。 The problem I'm finding is that when I load the solution, WebSite projects are not loaded into the Projects collection of the solution.
我发现的问题是,当我加载解决方案时,WebSite项目没有加载到解决方案的Projects集合中。
I've tried to convert those WebSite projects to WebApplication projects, then Roslyn was able to load the project, but when I look into the documents collection of the project, the documents (.cs files) of the App_Code folder are not there. 我试图将这些WebSite项目转换为WebApplication项目,然后Roslyn能够加载该项目,但是当我查看该项目的文档集合时,App_Code文件夹的文档(.cs文件)不存在。
The ideal scenario for my case would be to be able to make the static code analysis on the WebSite files (including app_code files) without having to convert it. 对于我而言,理想的方案是能够对WebSite文件(包括app_code文件)进行静态代码分析,而无需进行转换。
Does anyone knows why Roslyn couldn't load WebSite projects, or the App_Code documents in the case of the WebApplication? 有谁知道为什么Roslyn无法加载WebSite项目,或者对于WebApplication无法加载App_Code文档? Any suggestions?
有什么建议么?
The files inside the App_Code folder was not being recognized by Roslyn because the build action was set to "Content" instead of "Compile". Roslyn无法识别App_Code文件夹中的文件,因为构建操作被设置为“内容”而不是“编译”。 Changed the build action and the documents were loaded.
更改了构建操作,并加载了文档。
About WebSites not being loaded, looks like Roslyn needs the csproj file to understand the project. 关于未加载的WebSite,看起来Roslyn需要使用csproj文件来了解项目。 WebSites, as stated in comments, are not real projects and doesn't have that.
如评论中所述,网站不是真正的项目,也没有。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.