带有c#的位桶管道失败



所以我想让我的c#托管在比特桶上,以成功地运行管道。在我的windows机器上,无论是发布还是调试版本,一切都很好。

yml文件的第一个版本

image: mcr.microsoft.com/dotnet/core/sdk:3.1
pipelines:
default:
- parallel:
- step:
name: Build and Test
caches:
- dotnetcore
script:
- REPORTS_PATH=./test-reports/build_${BITBUCKET_BUILD_NUMBER}
- dotnet restore
- dotnet build --no-restore --configuration Release
- dotnet test --no-build --configuration Release --test-adapter-path:. --logger:"junit;LogFilePath=$REPORTS_PATH/junit.xml"
- step:
name: Lint the code
caches:
- dotnetcore
script:
- export SOLUTION_NAME=GameEnhancer
- export REPORTS_PATH=linter-reports
- dotnet new tool-manifest
- dotnet tool install JetBrains.ReSharper.GlobalTools
- dotnet tool restore
- dotnet jb inspectcode ${SOLUTION_NAME}.sln --output="${REPORTS_PATH}/jb-${BITBUCKET_BUILD_NUMBER}.xml"
artifacts:
- linter-reports/**

和.csproj文件:

<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<OutputType>WinExe</OutputType>
<TargetFramework>netcoreapp3.1</TargetFramework>
<UseWPF>true</UseWPF>
<StartupObject>GameEnhancer.App</StartupObject>
</PropertyGroup>
<ItemGroup>
<PackageReference Include="Ookii.Dialogs.Wpf" Version="3.1.0" />
<ProjectReference Include="..GameEnhancer.CoreGameEnhancer.Core.csproj" />
</ItemGroup>
</Project>

获取此错误:

dotnet build --no-restore --configuration Release
Microsoft (R) Build Engine version 16.7.2+b60ddb6f4 for .NET
Copyright (C) Microsoft Corporation. All rights reserved.
/usr/share/dotnet/sdk/3.1.416/Sdks/Microsoft.NET.Sdk/targets/Microsoft.NET.Sdk.DefaultItems.targets(349,5): warning NETSDK1107: Microsoft.NET.Sdk.WindowsDesktop is required to build Windows desktop applications. 'UseWpf' and 'UseWindowsForms' are not supported by the current SDK. [/opt/atlassian/pipelines/agent/build/GameEnhancer/GameEnhancer.csproj]
GameEnhancer.Core -> /opt/atlassian/pipelines/agent/build/GameEnhancer.Core/bin/Release/netcoreapp3.1/GameEnhancer.Core.dll
/usr/share/dotnet/sdk/3.1.416/Sdks/Microsoft.NET.Sdk/targets/Microsoft.NET.Sdk.FrameworkReferenceResolution.targets(283,5): error NETSDK1073: The FrameworkReference 'Microsoft.WindowsDesktop.App' was not recognized [/opt/atlassian/pipelines/agent/build/GameEnhancer/GameEnhancer.csproj]
Build FAILED.
/usr/share/dotnet/sdk/3.1.416/Sdks/Microsoft.NET.Sdk/targets/Microsoft.NET.Sdk.DefaultItems.targets(349,5): warning NETSDK1107: Microsoft.NET.Sdk.WindowsDesktop is required to build Windows desktop applications. 'UseWpf' and 'UseWindowsForms' are not supported by the current SDK. [/opt/atlassian/pipelines/agent/build/GameEnhancer/GameEnhancer.csproj]
/usr/share/dotnet/sdk/3.1.416/Sdks/Microsoft.NET.Sdk/targets/Microsoft.NET.Sdk.FrameworkReferenceResolution.targets(283,5): error NETSDK1073: The FrameworkReference 'Microsoft.WindowsDesktop.App' was not recognized [/opt/atlassian/pipelines/agent/build/GameEnhancer/GameEnhancer.csproj]
1 Warning(s)
1 Error(s)

当前.csproj文件:

<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<OutputType>WinExe</OutputType>
<TargetFramework>netcoreapp3.1</TargetFramework>
<UseWPF>true</UseWPF>
<StartupObject>GameEnhancer.App</StartupObject>
<GenerateErrorForMissingTargetingPacks>false</GenerateErrorForMissingTargetingPacks>
<MSBuildWarningsAsMessages>$(MSBuildWarningsAsMessages);NETSDK1107</MSBuildWarningsAsMessages>
</PropertyGroup>
<ItemGroup>
<PackageReference Include="Ookii.Dialogs.Wpf" Version="5.0.0" />
<ProjectReference Include="..GameEnhancer.CoreGameEnhancer.Core.csproj" />
<PackageReference Include="Microsoft.Windows.Compatibility" Version="6.0.0" />
<KnownFrameworkReference Update="Microsoft.WindowsDesktop.App.WPF" IsWindowsOnly="false" />
</ItemGroup>

</Project>

当前错误:

AssemblyInfo.cs(3,12): error CS0246: The type or namespace name 'ThemeInfoAttribute' could not be found (are you missing a using directive or an assembly reference?) [/opt/atlassian/pipelines/agent/build/GameEnhancer/GameEnhancer.csproj]
AssemblyInfo.cs(3,12): error CS0246: The type or namespace name 'ThemeInfo' could not be found (are you missing a using directive or an assembly reference?) [/opt/atlassian/pipelines/agent/build/GameEnhancer/GameEnhancer.csproj]
AssemblyInfo.cs(4,5): error CS0103: The name 'ResourceDictionaryLocation' does not exist in the current context [/opt/atlassian/pipelines/agent/build/GameEnhancer/GameEnhancer.csproj]
AssemblyInfo.cs(7,5): error CS0103: The name 'ResourceDictionaryLocation' does not exist in the current context [/opt/atlassian/pipelines/agent/build/GameEnhancer/GameEnhancer.csproj]
Partial/InjectConfigForm.xaml.cs(2,22): error CS0234: The type or namespace name 'Controls' does not exist in the namespace 'System.Windows' (are you missing an assembly reference?) [/opt/atlassian/pipelines/agent/build/GameEnhancer/GameEnhancer.csproj]
View/GameModsMenu.xaml.cs(10,22): error CS0234: The type or namespace name 'Controls' does not exist in the namespace 'System.Windows' (are you missing an assembly reference?) [/opt/atlassian/pipelines/agent/build/GameEnhancer/GameEnhancer.csproj]
View/GameModsMenu.xaml.cs(11,22): error CS0234: The type or namespace name 'Controls' does not exist in the namespace 'System.Windows' (are you missing an assembly reference?) [/opt/atlassian/pipelines/agent/build/GameEnhancer/GameEnhancer.csproj]
View/GameModsMenu.xaml.cs(13,22): error CS0234: The type or namespace name 'Media' does not exist in the namespace 'System.Windows' (are you missing an assembly reference?) [/opt/atlassian/pipelines/agent/build/GameEnhancer/GameEnhancer.csproj]
View/GameModsMenu.xaml.cs(14,22): error CS0234: The type or namespace name 'Media' does not exist in the namespace 'System.Windows' (are you missing an assembly reference?) [/opt/atlassian/pipelines/agent/build/GameEnhancer/GameEnhancer.csproj]
View/GameSelector.xaml.cs(8,22): error CS0234: The type or namespace name 'Controls' does not exist in the namespace 'System.Windows' (are you missing an assembly reference?) [/opt/atlassian/pipelines/agent/build/GameEnhancer/GameEnhancer.csproj]
View/MainMenu.xaml.cs(4,22): error CS0234: The type or namespace name 'Controls' does not exist in the namespace 'System.Windows' (are you missing an assembly reference?) [/opt/atlassian/pipelines/agent/build/GameEnhancer/GameEnhancer.csproj]
View/ModInfoEditor.xaml.cs(5,22): error CS0234: The type or namespace name 'Controls' does not exist in the namespace 'System.Windows' (are you missing an assembly reference?) [/opt/atlassian/pipelines/agent/build/GameEnhancer/GameEnhancer.csproj]
View/NewGameForm.xaml.cs(4,22): error CS0234: The type or namespace name 'Controls' does not exist in the namespace 'System.Windows' (are you missing an assembly reference?) [/opt/atlassian/pipelines/agent/build/GameEnhancer/GameEnhancer.csproj]
MainWindow.xaml.cs(8,39): error CS0246: The type or namespace name 'Window' could not be found (are you missing a using directive or an assembly reference?) [/opt/atlassian/pipelines/agent/build/GameEnhancer/GameEnhancer.csproj]
App.xaml.cs(8,32): error CS0246: The type or namespace name 'Application' could not be found (are you missing a using directive or an assembly reference?) [/opt/atlassian/pipelines/agent/build/GameEnhancer/GameEnhancer.csproj]
Partial/InjectConfigForm.xaml.cs(10,45): error CS0246: The type or namespace name 'UserControl' could not be found (are you missing a using directive or an assembly reference?) [/opt/atlassian/pipelines/agent/build/GameEnhancer/GameEnhancer.csproj]
View/MainMenu.xaml.cs(11,37): error CS0246: The type or namespace name 'Page' could not be found (are you missing a using directive or an assembly reference?) [/opt/atlassian/pipelines/agent/build/GameEnhancer/GameEnhancer.csproj]
View/GameSelector.xaml.cs(15,41): error CS0246: The type or namespace name 'Page' could not be found (are you missing a using directive or an assembly reference?) [/opt/atlassian/pipelines/agent/build/GameEnhancer/GameEnhancer.csproj]
View/MainMenu.xaml.cs(22,57): error CS0246: The type or namespace name 'RoutedEventArgs' could not be found (are you missing a using directive or an assembly reference?) [/opt/atlassian/pipelines/agent/build/GameEnhancer/GameEnhancer.csproj]
DialogUtility.cs(38,40): error CS0246: The type or namespace name 'UIElement' could not be found (are you missing a using directive or an assembly reference?) [/opt/atlassian/pipelines/agent/build/GameEnhancer/GameEnhancer.csproj]
View/MainMenu.xaml.cs(41,54): error CS0246: The type or namespace name 'RoutedEventArgs' could not be found (are you missing a using directive or an assembly reference?) [/opt/atlassian/pipelines/agent/build/GameEnhancer/GameEnhancer.csproj]
View/ModInfoEditor.xaml.cs(12,42): error CS0246: The type or namespace name 'Page' could not be found (are you missing a using directive or an assembly reference?) [/opt/atlassian/pipelines/agent/build/GameEnhancer/GameEnhancer.csproj]
View/GameSelector.xaml.cs(51,17): error CS0246: The type or namespace name 'Button' could not be found (are you missing a using directive or an assembly reference?) [/opt/atlassian/pipelines/agent/build/GameEnhancer/GameEnhancer.csproj]
View/NewGameForm.xaml.cs(11,40): error CS0246: The type or namespace name 'Page' could not be found (are you missing a using directive or an assembly reference?) [/opt/atlassian/pipelines/agent/build/GameEnhancer/GameEnhancer.csproj]
View/GameSelector.xaml.cs(65,57): error CS0246: The type or namespace name 'RoutedEventArgs' could not be found (are you missing a using directive or an assembly reference?) [/opt/atlassian/pipelines/agent/build/GameEnhancer/GameEnhancer.csproj]
View/NewGameForm.xaml.cs(38,56): error CS0246: The type or namespace name 'RoutedEventArgs' could not be found (are you missing a using directive or an assembly reference?) [/opt/atlassian/pipelines/agent/build/GameEnhancer/GameEnhancer.csproj]
View/NewGameForm.xaml.cs(44,54): error CS0246: The type or namespace name 'RoutedEventArgs' could not be found (are you missing a using directive or an assembly reference?) [/opt/atlassian/pipelines/agent/build/GameEnhancer/GameEnhancer.csproj]
View/NewGameForm.xaml.cs(51,53): error CS0246: The type or namespace name 'RoutedEventArgs' could not be found (are you missing a using directive or an assembly reference?) [/opt/atlassian/pipelines/agent/build/GameEnhancer/GameEnhancer.csproj]
View/GameModsMenu.xaml.cs(21,41): error CS0246: The type or namespace name 'Page' could not be found (are you missing a using directive or an assembly reference?) [/opt/atlassian/pipelines/agent/build/GameEnhancer/GameEnhancer.csproj]
View/GameModsMenu.xaml.cs(61,56): error CS0246: The type or namespace name 'DragEventArgs' could not be found (are you missing a using directive or an assembly reference?) [/opt/atlassian/pipelines/agent/build/GameEnhancer/GameEnhancer.csproj]
View/GameModsMenu.xaml.cs(95,16): error CS0246: The type or namespace name 'UIElement' could not be found (are you missing a using directive or an assembly reference?) [/opt/atlassian/pipelines/agent/build/GameEnhancer/GameEnhancer.csproj]
0 Warning(s)
31 Error(s)

注意:所以它无法使用System.Windows软件包。

这些线似乎没有什么区别:

<PackageReference Include="Microsoft.Windows.Compatibility" Version="6.0.0" />
<KnownFrameworkReference Update="Microsoft.WindowsDesktop.App.WPF" IsWindowsOnly="false" />

没有这条线:

<GenerateErrorForMissingTargetingPacks>false</GenerateErrorForMissingTargetingPacks>

错误为:

dotnet build --no-restore --configuration Release
Microsoft (R) Build Engine version 16.7.2+b60ddb6f4 for .NET
Copyright (C) Microsoft Corporation. All rights reserved.
GameEnhancer.Core -> /opt/atlassian/pipelines/agent/build/GameEnhancer.Core/bin/Release/netcoreapp3.1/GameEnhancer.Core.dll
/usr/share/dotnet/sdk/3.1.416/Sdks/Microsoft.NET.Sdk/targets/Microsoft.NET.Sdk.FrameworkReferenceResolution.targets(283,5): error NETSDK1073: The FrameworkReference 'Microsoft.WindowsDesktop.App' was not recognized [/opt/atlassian/pipelines/agent/build/GameEnhancer/GameEnhancer.csproj]
Build FAILED.
/usr/share/dotnet/sdk/3.1.416/Sdks/Microsoft.NET.Sdk/targets/Microsoft.NET.Sdk.FrameworkReferenceResolution.targets(283,5): error NETSDK1073: The FrameworkReference 'Microsoft.WindowsDesktop.App' was not recognized [/opt/atlassian/pipelines/agent/build/GameEnhancer/GameEnhancer.csproj]
0 Warning(s)
1 Error(s)

安装了dot-net核心框架,但也显示:

NETSDK1107: Microsoft.NET.Sdk.WindowsDesktop is required to build Windows desktop 

在这个框架中,有几个用于不同目的的"运行时间",您可以通过枚举

dotnet --list-runtimes

在我的例子中,我有:

>dotnet—列出运行时Microsoft.AspNetCore.App 3.1.18[C:\Program Files\dotnet\shared\Microsoft.AspNetCore.App]Microsoft.AspNetCore.App 5.0.9[C:\Program Files\dotnet\shared\Microsoft.AspNetCore.App]Microsoft.NETCore.App3.1.18[C:\Program Files\dotnet\shared\Microsoft.NETCore.App]Microsoft.NETCore.App 5.0.9[C:\Program Files\dotnet\shared\Microsoft.NETCore.App]Microsoft.WindowsDesktop.App 3.1.18[C:\Program Files\dotnet\shared\Microsoft.WindowsDesktop.App]Microsoft.WindowsDesktop.App 5.0.9[C:\Program Files\dotnet\shared\Microsoft.WindowsDesktop.App]

Microsoft没有告诉您的是,csproj本身应该针对正确的运行时。因此,在csproj的第一行,您应该替换:

<Project Sdk="Microsoft.NET.Sdk">

发件人:

<Project Sdk="Microsoft.NET.Sdk.WindowsDesktop">

如果你还没有这样做,最终会添加:

<UseWindowsForms>true</UseWindowsForms>

在你推送并检查管道通行证后,投票!订阅我的Youtube频道!

WPF仅限于Windows操作系统:https://learn.microsoft.com/en-us/answers/questions/19216/wpf-in-linux.html

根据这个博客(https://devblogs.microsoft.com/dotnet/announcing-net-5-0-preview-1/),.NET Core和.NET 5(最新的.NET平台(将支持WPF。但看起来支持仅限于Windows操作系统。

位桶管道在Linux上运行的主要问题。所以,基本上,您正在尝试在Linux上构建WPF应用程序,而这是微软不支持的。

最新更新