在 VS Code 中,我有以下 C# 项目:
- Common/Common.csproj
- WebApi1/WebApi1.csproj
- WebApi2/WebApi2.csproj
Run Code Online (Sandbox Code Playgroud)
我的tasks.json如下:
{
"version": "2.0.0",
"tasks": [
{
"label": "build",
"command": "dotnet",
"type": "process",
"args": [
"build",
"${workspaceFolder}/WebApi1/WebApi1.csproj"
],
"problemMatcher": "$msCompile"
}
]
}
Run Code Online (Sandbox Code Playgroud)
当我点击调试选择 WebApi1 配置文件时,我launch.json运行任务build(在前面的代码部分中定义),并且该任务WebApi1.csproj与 一起构建项目Common.csproj,因为 Common 被定义为依赖项。
我的问题是:如何使用相同的任务来构建 WebApi1 和 WebApi2(以及 WebApi3、WebApi4 等),这意味着一个任务可以构建存储库中的所有项目。
我已经尝试过"${workspaceFolder}/**/*.csproj",但这种语法不被接受。
我有一个 ASP.NET Core 3.0 项目在以下启动时运行良好:
public void ConfigureServices(IServiceCollection services)
{
services.AddCors();
services.AddControllers();
}
Run Code Online (Sandbox Code Playgroud)
现在我想将此设置移动到另一个项目,作为一个 Common dll,供数十个其他 ASP.NET Core 3.0 项目使用,所有这些项目都将通过调用 just 来执行启动services.Configure();,考虑到这Configure将是创建的扩展方法由我。
为此,我使用以下 .csproj 文件创建了另一个项目:
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<TargetFramework>netstandard2.1</TargetFramework>
</PropertyGroup>
<ItemGroup>
<PackageReference Include="Microsoft.AspNetCore.Mvc" Version="2.2.0" />
<PackageReference Include="Microsoft.AspNetCore.Cors" Version="2.2.0" />
<PackageReference Include="Microsoft.Extensions.DependencyInjection.Abstractions" Version="2.2.0" />
</ItemGroup>
</Project>
Run Code Online (Sandbox Code Playgroud)
以及以下课程:
using System;
using Microsoft.Extensions.DependencyInjection;
namespace MyCommon.Extensions
{
public static class MyIServiceCollectionExtensions
{
public static class IServiceCollectionExtensions
{
public static IServiceCollection Configure(this IServiceCollection services)
{
services.AddCors();
services.AddControllers();
return services;
}
} …Run Code Online (Sandbox Code Playgroud) 在 Visual Studio 中,可以创建“解决方案文件夹”以将不同的 .NET 项目分组到一个虚拟文件夹中。VS Code 有等效的解决方案吗?
我尝试安装扩展vscode-solution-explorer,但它不支持虚拟文件夹。
在 .NET Core 2.2 中,在我的Startup.cs.
public void ConfigureServices(IServiceCollection services)
{
services.AddDistributedRedisCache(...);
}
Run Code Online (Sandbox Code Playgroud)
但是现在,在 .NET Core 3.0 中,AddDistributedRedisCache找不到该方法。在docs 中,“适用于”部分显示仅支持 .NET Core 2.2
按照Microsoft 的本教程,他们services.AddStackExchangeRedisCache在示例中使用。这是否意味着我需要为 Redis 安装 Stack Exchange NuGet 包?为什么微软原生的Redis客户端解决方案被移除了?