我从多个来源中发现,在我们的 .NET Core 项目中设置 SDK 版本的官方方法是将 global.json 文件添加到项目主文件夹中。
顺便说一下,让我提醒一些有用的 cli 命令来运行到您的项目文件夹中:
dotnet --list-sdks 列出所有已安装的 SDK
dotnet new globaljson --sdk-version 2.2.105 创建适当的 global.json 文件
现在我的问题:
global.json 未应用,显示的版本与我的 global.json 不匹配
我的 csproj:
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<OutputType>Exe</OutputType>
<TargetFramework>netcoreapp2.2</TargetFramework>
<LangVersion>7.3</LangVersion>
</PropertyGroup>
<ItemGroup>
<PackageReference Include="Microsoft.EntityFrameworkCore.Tools" Version="2.2.3">
<PrivateAssets>all</PrivateAssets>
<IncludeAssets>runtime; build; native; contentfiles; analyzers</IncludeAssets>
</PackageReference>
</ItemGroup>
<ItemGroup>
<ProjectReference Include="..\..\EmargementsListeners.Application\EmargementsListeners.Application.csproj" />
<ProjectReference Include="..\..\EmargementsListeners.EmargProviders\Emp.Source.FakeRandomisedXbus\Emp.Source.FakeRandomisedXbus.csproj" />
<ProjectReference Include="..\..\EmargementsListeners.Persistence\EmargementsListeners.Persistence.csproj" />
</ItemGroup>
<ItemGroup>
<None Update="appsettings.json">
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
</None>
</ItemGroup>
</Project>
Run Code Online (Sandbox Code Playgroud)
我的 global.json:
{
"sdk": {
"version": "2.2.105"
}
}
Run Code Online (Sandbox Code Playgroud)
结果:
如您所见,sdk 版本与global.json …
我不明白为什么我的测试返回:
\n\n\n\n\nSystem.InvalidOperationException :测试方法需要 1 个参数值,但提供了 0 个参数值。异常没有堆栈跟踪
\n
虽然我的非常基本的测试与这里和那里找到的示例相匹配:
\n\n [Theory]\n [InlineData("\xe2\x80\x98")]\n [InlineData("\xc2\xab")]\n [InlineData("\xc2\xa3")]\n [InlineData("\xe2\x82\xac")]\n [InlineData("\xc3\xa0")]\n [InlineData("\xc3\xa9")]\n [InlineData("\xc3\xae")]\n [InlineData("\xc3\xaf")]\n public void IsAsciiComplient_Fail(string c)\n {\n //Act\n bool actual = c.IsAsciiComplient();\n\n //Test\n Assert.False(actual);\n }\nRun Code Online (Sandbox Code Playgroud)\n\n我也尝试过用 char 而不是 string,但没有成功。
\n\n由于没有堆栈跟踪,我该如何修复它?\n任何关于出了什么问题的线索吗?
\n