gpt4 book ai didi

azure - 如何使用Azure Pipeline构建语言版本 'preview'的.Net Core 5项目?

转载 作者:行者123 更新时间:2023-12-02 07:22:42 26 4
gpt4 key购买 nike

我有一个在 Visual Studio 2019 预览版中构建的 .Net Core DLL 项目,但当我尝试使用 Azure Pipeline 进行构建时,我收到了一长串与预览版 SDK 中的新语言相关的错误。

这是 csproject 文件的一部分:

<PropertyGroup>
<TargetFramework>net5.0</TargetFramework>
<Nullable>enable</Nullable>
<LangVersion>preview</LangVersion>
<NeutralLanguage>en-US</NeutralLanguage>
WarningsAsErrors>NU1605;CS8600;CS8601;CS8602;CS8603;CS8604;CS8610;CS8613;CS8614;CS8618;CS8619;CS8625;CS8629;CS8714</WarningsAsErrors>
<AllowUnsafeBlocks>true</AllowUnsafeBlocks>
</PropertyGroup>

这是 Azure Pipeline yml:

# ASP.NET Core
# Build and test ASP.NET Core projects targeting .NET Core.
# Add steps that run tests, create a NuGet package, deploy, and more:
# https://learn.microsoft.com/azure/devops/pipelines/languages/dotnet-core

trigger:
- master

pool:
vmImage: 'windows-latest'

variables:
buildConfiguration: 'Release'

steps:
- task: UseDotNet@2
displayName: 'Install .Net Core SDK'
inputs:
packageType: 'sdk'
version: '5.0.100-preview.4.20258.7'

- task: NuGetAuthenticate@0
displayName: 'Authenticate'

- script: dotnet build --configuration $(buildConfiguration)
displayName: 'Build Project'

- task: DotNetCoreCLI@2
displayName: 'Pack Project'
inputs:
command: 'pack'
packagesToPack: '**/*.csproj'
versioningScheme: 'off'

- task: DotNetCoreCLI@2
displayName: 'Push Nuget Package'
inputs:
command: 'push'
packagesToPush: '$(Build.ArtifactStagingDirectory)/*.nupkg'
nuGetFeedType: 'internal'
publishVstsFeed: 'my feed key'

以下是错误:

Starting: dotnet build Release
==============================================================================
Task : Command line
Description : Run a command line script using Bash on Linux and macOS and cmd.exe on Windows
Version : 2.164.1
Author : Microsoft Corporation
Help : https://learn.microsoft.com/azure/devops/pipelines/tasks/utility/command-line
...
Welcome to .NET 5.0!
---------------------
SDK Version: 5.0.100-preview.4.20258.7
...
--------------------------------------------------------------------------------------
Microsoft (R) Build Engine version 16.7.0-preview-20220-01+80e487bff for .NET Core
Copyright (C) Microsoft Corporation. All rights reserved.
...
Barcodes/AztecCode.cs(1007,19): error CS1002: ; expected [/home/vsts/work/1/s/CompanyName.OS.Documents/CompanyName.OS.Documents.csproj]
Barcodes/AztecCode.cs(1007,23): error CS1002: ; expected [/home/vsts/work/1/s/CompanyName.OS.Documents/CompanyName.OS.Documents.csproj]
ZPLProcessor/ZPLProcessor.cs(102,102): error CS8124: Tuple must contain at least two elements. [/home/vsts/work/1/s/CompanyName.OS.Documents/CompanyName.OS.Documents.csproj]
Barcodes/AztecCode.cs(1007,23): error CS1513: } expected [/home/vsts/work/1/s/CompanyName.OS.Documents/CompanyName.OS.Documents.csproj]
ZPLProcessor/ZPLProcessor.cs(102,103): error CS1526: A new expression requires (), [], or {} after type [/home/vsts/work/1/s/CompanyName.OS.Documents/CompanyName.OS.Documents.csproj]
Barcodes/AztecCode.cs(1007,26): error CS1002: ; expected [/home/vsts/work/1/s/CompanyName.OS.Documents/CompanyName.OS.Documents.csproj]
Barcodes/AztecCode.cs(1007,26): error CS1513: } expected [/home/vsts/work/1/s/CompanyName.OS.Documents/CompanyName.OS.Documents.csproj]
Barcodes/AztecCode.cs(1009,13): error CS1002: ; expected [/home/vsts/work/1/s/CompanyName.OS.Documents/CompanyName.OS.Documents.csproj]
Barcodes/AztecCode.cs(1009,13): error CS1513: } expected [/home/vsts/work/1/s/CompanyName.OS.Documents/CompanyName.OS.Documents.csproj]
Barcodes/AztecCode.cs(1012,5): error CS1022: Type or namespace definition, or end-of-file expected [/home/vsts/work/1/s/CompanyName.OS.Documents/CompanyName.OS.Documents.csproj]
Barcodes/AztecCode.cs(1014,2): error CS1022: Type or namespace definition, or end-of-file expected [/home/vsts/work/1/s/CompanyName.OS.Documents/CompanyName.OS.Documents.csproj]
Barcodes/AztecCode.cs(1015,1): error CS1022: Type or namespace definition, or end-of-file expected [/home/vsts/work/1/s/CompanyName.OS.Documents/CompanyName.OS.Documents.csproj]
Barcodes/Code93.cs(62,41): error CS8124: Tuple must contain at least two elements. [/home/vsts/work/1/s/CompanyName.OS.Documents/CompanyName.OS.Documents.csproj]
Barcodes/Code93.cs(62,41): error CS1026: ) expected [/home/vsts/work/1/s/CompanyName.OS.Documents/CompanyName.OS.Documents.csproj]
Barcodes/Code93.cs(62,41): error CS1526: A new expression requires (), [], or {} after type [/home/vsts/work/1/s/CompanyName.OS.Documents/CompanyName.OS.Documents.csproj]
Barcodes/Code93.cs(62,44): error CS1002: ; expected [/home/vsts/work/1/s/CompanyName.OS.Documents/CompanyName.OS.Documents.csproj]
Barcodes/Code93.cs(62,44): error CS1513: } expected [/home/vsts/work/1/s/CompanyName.OS.Documents/CompanyName.OS.Documents.csproj]
Barcodes/Code93.cs(62,49): error CS1002: ; expected [/home/vsts/work/1/s/CompanyName.OS.Documents/CompanyName.OS.Documents.csproj]
Barcodes/Code93.cs(62,49): error CS1513: } expected [/home/vsts/work/1/s/CompanyName.OS.Documents/CompanyName.OS.Documents.csproj]
Barcodes/Code93.cs(62,54): error CS1002: ; expected [/home/vsts/work/1/s/CompanyName.OS.Documents/CompanyName.OS.Documents.csproj]
Barcodes/Code93.cs(62,54): error CS1513: } expected [/home/vsts/work/1/s/CompanyName.OS.Documents/CompanyName.OS.Documents.csproj]
Element.cs(160,81): error CS8124: Tuple must contain at least two elements. [/home/vsts/work/1/s/CompanyName.OS.Documents/CompanyName.OS.Documents.csproj]
Barcodes/Code128.cs(41,41): error CS8124: Tuple must contain at least two elements. [/home/vsts/work/1/s/CompanyName.OS.Documents/CompanyName.OS.Documents.csproj]
Barcodes/Code128.cs(41,41): error CS1026: ) expected [/home/vsts/work/1/s/CompanyName.OS.Documents/CompanyName.OS.Documents.csproj]
Barcodes/Code128.cs(41,41): error CS1526: A new expression requires (), [], or {} after type [/home/vsts/work/1/s/CompanyName.OS.Documents/CompanyName.OS.Documents.csproj]
Barcodes/Code128.cs(41,44): error CS1002: ; expected [/home/vsts/work/1/s/CompanyName.OS.Documents/CompanyName.OS.Documents.csproj]
Barcodes/Code128.cs(41,44): error CS1513: } expected [/home/vsts/work/1/s/CompanyName.OS.Documents/CompanyName.OS.Documents.csproj]
Barcodes/Code128.cs(41,49): error CS1002: ; expected [/home/vsts/work/1/s/CompanyName.OS.Documents/CompanyName.OS.Documents.csproj]
Barcodes/Code128.cs(41,49): error CS1513: } expected [/home/vsts/work/1/s/CompanyName.OS.Documents/CompanyName.OS.Documents.csproj]
Barcodes/Code128.cs(41,54): error CS1002: ; expected [/home/vsts/work/1/s/CompanyName.OS.Documents/CompanyName.OS.Documents.csproj]
Barcodes/Code128.cs(41,54): error CS1513: } expected [/home/vsts/work/1/s/CompanyName.OS.Documents/CompanyName.OS.Documents.csproj]
0 Warning(s)
80 Error(s)

我不知道我在这里做错了什么。为什么在 VS 中构建但 Azure Pipeline 却显示有错误?

<小时/>

编辑1

这是导致错误的一些代码:这里使用新语言初始化栏是问题

public static IReadOnlyList<byte> GetBars(string data)
{
// this initialization causes an error
List<byte> bars = new (((data.Length + 8) * 6) + 1);
...
}

返回新的(67, 1);在函数 GetRSEncoder(int codewordSize) 中就是问题所在。

internal class RSEncoder<T> where T : struct, IConvertible
{
public RSEncoder(int primePoly, int initialExponent)
{
...
}
}

private static readonly ConcurrentDictionary<int, RSEncoder<short>> RSEncoders = new ConcurrentDictionary<int, RSEncoder<short>>();
private static RSEncoder<short> GetRSEncoder(int codewordSize)
{
return RSEncoders.GetOrAdd(codewordSize, (size) =>
{
switch (size)
{
case 6:
return new (67, 1);

case 8:
return new (301, 1);

case 10:
return new (1033, 1);

case 12:
return new (4201, 1);

default:
throw new Exception("Invalid codeword size");
}
});
}

最佳答案

我遇到了类似的问题。为了解决这个问题,请在 UseDotNet@2 任务中将 PerformMultiLevelLookup 标志设置为 true 以及 Windows 最新的管道设置。请引用这篇文章:https://learn.microsoft.com/pl-pl/azure/devops/pipelines/tasks/reference/use-dotnet-v2?view=azure-pipelines

关于azure - 如何使用Azure Pipeline构建语言版本 'preview'的.Net Core 5项目?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/62179944/

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