gpt4 book ai didi

c# - 在 csproj 中标记程序集 CLSCompliant

转载 作者:行者123 更新时间:2023-12-04 00:59:20 25 4
gpt4 key购买 nike

在此回复 question解释如何设置 InternalsVisibleTo csproj .

我认为这也适用于 CLSCompliant :

<ItemGroup>
<AssemblyAttribute Include="System.CLSCompliant">
<_Parameter1>true</_Parameter1>
</AssemblyAttribute>
</ItemGroup>

但不是! MSBuild 提示 true无法转换为 from stringbool :

> dotnet build
Microsoft (R) Build Engine version 16.4.0+e901037fe for .NET Core
Copyright (C) Microsoft Corporation. All rights reserved.

Restore completed in 418.35 ms for C:\Users\coder\OneDrive\Projects\pickall\src\PickAll.Sample\PickAll.Sample.csproj.
Restore completed in 418.33 ms for C:\Users\coder\OneDrive\Projects\pickall\src\PickAll.Specs\PickAll.Specs.csproj.
Restore completed in 418.33 ms for C:\Users\coder\OneDrive\Projects\pickall\src\PickAll\PickAll.csproj.
obj\Debug\netstandard2.0\PickAll.AssemblyInfo.cs(14,32): error CS1503: Argument 1: cannot convert from 'string' to 'bool' [C:\Users\coder\OneDrive\Projects\pickall\src\PickAll\PickAll.csproj]
obj\Debug\net461\PickAll.AssemblyInfo.cs(14,32): error CS1503: Argument 1: cannot convert from 'string' to 'bool' [C:\Users\coder\OneDrive\Projects\pickall\src\PickAll\PickAll.csproj]

Build FAILED.

obj\Debug\netstandard2.0\PickAll.AssemblyInfo.cs(14,32): error CS1503: Argument 1: cannot convert from 'string' to 'bool' [C:\Users\coder\OneDrive\Projects\pickall\src\PickAll\PickAll.csproj]
obj\Debug\net461\PickAll.AssemblyInfo.cs(14,32): error CS1503: Argument 1: cannot convert from 'string' to 'bool' [C:\Users\coder\OneDrive\Projects\pickall\src\PickAll\PickAll.csproj]
0 Warning(s)
2 Error(s)

Time Elapsed 00:00:18.37

有没有办法正确写出 bool 文字 _Parameter1标签?

最佳答案

最近在 MSBuild 存储库中合并了一个拉取请求( Allow parameter type name to be specified for WriteCodeFragment task ),它可以完全按照原始问题中的描述在 csproj 文件中标记程序集 CLSCompliant。
应该是 available soon (2021 年 5 月)版本 16.10 预览版 3(不确定是指 MSBuild 版本还是 Visual Studio 版本)。从提到的拉取请求评论中引用用户 Forgind:

This should be available in 16.10 preview 3. I will try to remember to ping you in this thread when that's available. That should be roughly a month from now.

关于c# - 在 csproj 中标记程序集 CLSCompliant,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/59927051/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com