【发布时间】:2022-10-05 15:55:58
【问题描述】:
所以我想让我在 bitbucket 上托管的 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.Core\\GameEnhancer.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.Core\\GameEnhancer.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)
标签: c# wpf .net-core continuous-integration bitbucket-pipelines