简体   繁体   English

使用Roslyn(Microsoft.CodeAnalysis)查询WebSite项目的信息

[英]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.

相关问题 在Roslyn与Microsoft.CodeAnalysis中添加MetadataReference - Adding MetadataReference in Roslyn Vs Microsoft.CodeAnalysis 如何在 memory 中编译并使用 Microsoft.CodeAnalysis 获取程序集 - How to compile in memory and get assembly using Microsoft.CodeAnalysis 如何在Roslyn(Microsoft.CodeAnalysis)中向生成的方法添加参数? -需要确切的语法 - How to add parameters to generated method in Roslyn ( Microsoft.CodeAnalysis )? - Need exact syntax 在Roslyn的新版本(Microsoft.CodeAnalysis)中,`Solution.LoadStandAloneProject`发生了什么? - What happened to `Solution.LoadStandAloneProject` in Roslyn's new version (Microsoft.CodeAnalysis)? 无法加载文件或程序集 Microsoft.CodeAnalysis - Could not load file or assembly Microsoft.CodeAnalysis Microsoft.CodeAnalysis无法加载文件 - Microsoft.CodeAnalysis failed to load file 在哪里阅读Microsoft.CodeAnalysis的文档? - Where to read docs for Microsoft.CodeAnalysis? 使用 Microsoft.CodeAnalysis,如何获取 Type 类型的 Attribute 属性的值? - Using Microsoft.CodeAnalysis, how do I get the value of an Attribute property that is of type Type? 如何使用 Microsoft.CodeAnalysis(或类似)获取项目(.csproj)的目标框架? - How to get the Target Framework/s of a project (.csproj) using Microsoft.CodeAnalysis (or similar)? 为什么 Microsoft 分析器找不到 Microsoft.CodeAnalysis? - Why can't Microsoft analyzers find Microsoft.CodeAnalysis?
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM