roslyn

dotnet 配合 GitHub 的 Action 做自动推 Tag 时打包 NuGet 包

陌路散爱 提交于 2020-08-10 15:38:27
被微软收购的 GitHub 越来越好用,拥有大量免费的工具资源和构建服务器资源,再加上私有项目的无限制使用,我有大量的项目都在向 GitHub 迁移。通过 GitHub 的 Action 的自动构建,可以用上微软土豪的服务器资源,进行自动化测试和构建。对于 CBB 来说,发布就是打出 NuGet 包然后上传到内部 NuGet 服务器。此时遇到的问题是,如何在 GitHub 上执行打包,打包的时候如何指定 NuGet 包的版本号。因为 CBB 的特殊性,我要求每个 NuGet 正式发布的包都应该有一个对应的 Tag 号,这样将 NuGet 库安装到项目里面,之后发现问题了还能找到对应版本的代码 在阅读本文之前,期望小伙伴能了解如何在 dotnet 下使用 GitHub 的 Action 进行自动构建,请看 dotnet 部署 github 的 Action 进行持续集成 而发布 NuGet 包的方法请看 dotnet 配置 github 自动打包上传 nuget 文件 本文将在此基础上实现本地推送一个 Tag 到 GitHub 服务器上,就会触发 GitHub 的 Action 的自动构建,自动构建的 NuGet 包的版本就是 Tag 版本。为什么需要在推 Tag 打包,请看 dotnet CBB 为什么决定推送 Tag 才能打包 本文将用到一个 dotnet tool 工具,在

CA1005: Avoid excessive parameters on generic types

做~自己de王妃 提交于 2020-08-08 17:32:08
CA1005: Avoid excessive parameters on generic types https://docs.microsoft.com/en-us/visualstudio/code-quality/install-roslyn-analyzers?view=vs-2019 需要先进行安装 Cause An externally visible generic type has more than two type parameters. Rule description The more type parameters a generic type contains, the more difficult it is to know and remember what each type parameter represents. It is usually obvious with one type parameter, as in List<T> , and in certain cases with two type parameters, as in Dictionary<TKey, TValue> . If more than two type parameters exist, the difficulty becomes too great

asp.net core与.net core

会有一股神秘感。 提交于 2020-07-24 14:32:26
基于.net core的应用程序能够运行在不同的操作系统平台。Asp.net core是基于.net core平台的Web开发框架。 .NET Core简介 CoreCLR 基类库 Roslyn编译器 .NET Cire CLI工具 Asp.net core具有以下有点: 跨平台 统一Web UI与Web API开发 基于环境配置以及云就绪配置 内置依赖注入 轻型的高性能模块化HTTP请求管道 能够在IIS、Nginx、Apache和Docker上进行托管或者在当前进程内自托管 基于 .net core的框架 简化新式Web开发工具,命令行或者Visual Studio Code、Visual Studio 在Visual Studio Code上的开发插件:vscode-solution-explorer、c#、vscode-icon、NuGet Package Manager、C# XML Documentation Comments, vscode-drawio(做图插件) 创建一个web应用,命名为demo 然后点击运行项目 在浏览器里面输入http://localhost:5000 来源: oschina 链接: https://my.oschina.net/it110/blog/4326341

Roslyn error only with .NET Core: “ResolvePackageFileConflicts” task failed unexpectedly

这一生的挚爱 提交于 2020-07-10 07:01:11
问题 My code is responsible for get types namespaces using Roslyn API based on solution file path; before i find out namespaces, i get the documents with: using (var ws = MSBuildWorkspace.Create()) { var solution = await ws.OpenSolutionAsync(solutionPath); //[...] some code var diagnostics = ws.Diagnostics; //[...] some code return solution.Projects.SelectMany(p => p.Documents); } When i pass as parameter some solution file path from a .NET Framework solution, the code works fine. But when i pass

Roslyn error only with .NET Core: “ResolvePackageFileConflicts” task failed unexpectedly

故事扮演 提交于 2020-07-10 07:00:40
问题 My code is responsible for get types namespaces using Roslyn API based on solution file path; before i find out namespaces, i get the documents with: using (var ws = MSBuildWorkspace.Create()) { var solution = await ws.OpenSolutionAsync(solutionPath); //[...] some code var diagnostics = ws.Diagnostics; //[...] some code return solution.Projects.SelectMany(p => p.Documents); } When i pass as parameter some solution file path from a .NET Framework solution, the code works fine. But when i pass

Roslyn getting dependencies for class

核能气质少年 提交于 2020-06-25 03:16:59
问题 I'm trying to determine for a class, what does it reference (other namespaces, or external library namespaces). Seems like out of box for a given document/syntaxtree etc, theres no way to do that... and more that I need to just Use symbol finder, iterate through every file in the entire code base, and call find, sticking found references in a map, and then navigating the map backwards. Am I wrong here? Am I missing something simple? I'm just trying to build a dependency graph... If I start

How to load solution in Roslyn?

人盡茶涼 提交于 2020-05-29 07:47:49
问题 Here is my code that used to work: MSBuildWorkspace msBuild = MSBuildWorkspace.Create(); Solution sln = await msBuild.OpenSolutionAsync(solutionPath); but now I get: int pr = sln.Projects.Count();//is 1 instead of 2. and: int docs = sln.Projects.First().Documents.Count();//is 0 Have they changed it again? (If it matters, I need the Solution in order to iterate over fields etc. and use Renamer.RenameSymbolAsync .) 回答1: The way I did it was like so: if (!MSBuildLocator.IsRegistered)

Getting a SemanticModel of a cshtml file?

瘦欲@ 提交于 2020-05-12 22:33:21
问题 I'd like to use Roslyn to analyze semantic information within the context of a block of C# code inside a Razor View. Is there any way (within Visual Studio 2015, or even in a unit test) to get the SemanticModel that represents this code? 回答1: Razor files contain a C# projection buffer with the generated C# code (including the parts that you don't write yourself). This buffer has full Roslyn services and is exactly what you're looking for. You need to walk through the TextView's BufferGraph

Getting a SemanticModel of a cshtml file?

Deadly 提交于 2020-05-12 22:23:54
问题 I'd like to use Roslyn to analyze semantic information within the context of a block of C# code inside a Razor View. Is there any way (within Visual Studio 2015, or even in a unit test) to get the SemanticModel that represents this code? 回答1: Razor files contain a C# projection buffer with the generated C# code (including the parts that you don't write yourself). This buffer has full Roslyn services and is exactly what you're looking for. You need to walk through the TextView's BufferGraph

Getting a SemanticModel of a cshtml file?

岁酱吖の 提交于 2020-05-12 22:23:45
问题 I'd like to use Roslyn to analyze semantic information within the context of a block of C# code inside a Razor View. Is there any way (within Visual Studio 2015, or even in a unit test) to get the SemanticModel that represents this code? 回答1: Razor files contain a C# projection buffer with the generated C# code (including the parts that you don't write yourself). This buffer has full Roslyn services and is exactly what you're looking for. You need to walk through the TextView's BufferGraph