.Net MAUI Windows 发布
.Net MAUI Windows Publishing
我正在尝试为 windows 创建我的 MAUI Blazor 应用程序的可安装工件。从我的所有研究中,我要 运行 使用 MSBuild 的以下命令。
"C:\Program Files\Microsoft Visual Studio22\Preview\MSBuild\Current\Bin\msbuild" /restore /t:Publish /p:TargetFramework=net6.0-windows10.0.19041 /p:configuration=release /p:GenerateAppxPackageOnBuild=true /p:AppxPackageSigningEnabled=true /p:PackageCertificateThumbprint="{myThumbPrint}" /p:PackageCertificatePassword="{myPassword}"
但是,当我 运行 命令时,我得到一长串错误。 (我可以通过 Visual Studio 毫无问题地调试应用程序)
Build FAILED.
"PathToMyProject\myProject.csproj" (Restore target)
(1) ->
(Restore target) ->
PathToMyProject\myProject.csproj : error NU1605:
Detected package downgrade: Microsoft.Graphics.Win2D from 1.0.0.30 to 1.0.0.29-preview3. Reference the package directly
from the project to select a different version.
PathToMyProject\myProject.csproj : error NU1605: S
DS2.JobScheduler.Client -> Microsoft.Maui.Dependencies 6.0.200-preview.13.2865 -> Microsoft.Graphics.Win2D (>= 1.0.0.30
)
PathToMyProject\myProject.csproj : error NU1605: S
DS2.JobScheduler.Client -> Microsoft.Graphics.Win2D (>= 1.0.0.29-preview3)
PathToMyProject\myProject.csproj : error NU1605:
Detected package downgrade: Microsoft.WindowsAppSDK from 1.0.0 to 1.0.0-preview3. Reference the package directly from t
he project to select a different version.
PathToMyProject\myProject.csproj : error NU1605: S
DS2.JobScheduler.Client -> Microsoft.Maui.Dependencies 6.0.200-preview.13.2865 -> Microsoft.WindowsAppSDK (>= 1.0.0)
PathToMyProject\myProject.csproj : error NU1605: S
DS2.JobScheduler.Client -> Microsoft.WindowsAppSDK (>= 1.0.0-preview3)
PathToMyProject\myProject.csproj : error NU1605:
Detected package downgrade: Microsoft.Graphics.Win2D from 1.0.0.30 to 1.0.0.29-preview3. Reference the package directly
from the project to select a different version.
PathToMyProject\myProject.csproj : error NU1605: S
DS2.JobScheduler.Client -> Microsoft.AspNetCore.Components.WebView.Maui 6.0.200-preview.13.2865 -> Microsoft.Graphics.W
in2D (>= 1.0.0.30)
PathToMyProject\myProject.csproj : error NU1605: S
DS2.JobScheduler.Client -> Microsoft.Graphics.Win2D (>= 1.0.0.29-preview3)
PathToMyProject\myProject.csproj : error NU1605:
Detected package downgrade: Microsoft.WindowsAppSDK from 1.0.0 to 1.0.0-preview3. Reference the package directly from t
he project to select a different version.
PathToMyProject\myProject.csproj : error NU1605: S
DS2.JobScheduler.Client -> Microsoft.AspNetCore.Components.WebView.Maui 6.0.200-preview.13.2865 -> Microsoft.WindowsApp
SDK (>= 1.0.0)
PathToMyProject\myProject.csproj : error NU1605: S
DS2.JobScheduler.Client -> Microsoft.WindowsAppSDK (>= 1.0.0-preview3)
PathToMyProject\myProject.csproj : error NU1201:
Project MyProject.Common is not compatible with net6.0-android31.0 (.NETCoreApp,Version=v6.0). Project SDS2.Job
Scheduler.Common supports: net6.0-windows10.0.19041 (.NETCoreApp,Version=v6.0)
PathToMyProject\myProject.csproj : error NU1201:
Project MyProject.Common is not compatible with net6.0-ios15.2 (.NETCoreApp,Version=v6.0). Project SDS2.JobSche
duler.Common supports: net6.0-windows10.0.19041 (.NETCoreApp,Version=v6.0)
PathToMyProject\myProject.csproj : error NU1201:
Project MyProject.Common is not compatible with net6.0-maccatalyst15.2 (.NETCoreApp,Version=v6.0). Project SDS2
.JobScheduler.Common supports: net6.0-windows10.0.19041 (.NETCoreApp,Version=v6.0)
PathToMyProject\myProject.csproj : error NU1201:
Project MyProject.Common is not compatible with net6.0-android31.0 (.NETCoreApp,Version=v6.0) / win-x64. Projec
t MyProject.Common supports: net6.0-windows10.0.19041 (.NETCoreApp,Version=v6.0)
PathToMyProject\myProject.csproj : error NU1201:
Project MyProject.Common is not compatible with net6.0-android31.0 (.NETCoreApp,Version=v6.0) / win10-arm64. Pr
oject MyProject.Common supports: net6.0-windows10.0.19041 (.NETCoreApp,Version=v6.0)
PathToMyProject\myProject.csproj : error NU1201:
Project MyProject.Common is not compatible with net6.0-android31.0 (.NETCoreApp,Version=v6.0) / win10-x64. Proj
ect MyProject.Common supports: net6.0-windows10.0.19041 (.NETCoreApp,Version=v6.0)
PathToMyProject\myProject.csproj : error NU1201:
Project MyProject.Common is not compatible with net6.0-android31.0 (.NETCoreApp,Version=v6.0) / win10-x86. Proj
ect MyProject.Common supports: net6.0-windows10.0.19041 (.NETCoreApp,Version=v6.0)
PathToMyProject\myProject.csproj : error NU1201:
Project MyProject.Common is not compatible with net6.0-ios15.2 (.NETCoreApp,Version=v6.0) / win-x64. Project SD
S2.JobScheduler.Common supports: net6.0-windows10.0.19041 (.NETCoreApp,Version=v6.0)
PathToMyProject\myProject.csproj : error NU1201:
Project MyProject.Common is not compatible with net6.0-ios15.2 (.NETCoreApp,Version=v6.0) / win10-arm64. Projec
t MyProject.Common supports: net6.0-windows10.0.19041 (.NETCoreApp,Version=v6.0)
PathToMyProject\myProject.csproj : error NU1201:
Project MyProject.Common is not compatible with net6.0-ios15.2 (.NETCoreApp,Version=v6.0) / win10-x64. Project
MyProject.Common supports: net6.0-windows10.0.19041 (.NETCoreApp,Version=v6.0)
PathToMyProject\myProject.csproj : error NU1201:
Project MyProject.Common is not compatible with net6.0-ios15.2 (.NETCoreApp,Version=v6.0) / win10-x86. Project
MyProject.Common supports: net6.0-windows10.0.19041 (.NETCoreApp,Version=v6.0)
PathToMyProject\myProject.csproj : error NU1201:
Project MyProject.Common is not compatible with net6.0-maccatalyst15.2 (.NETCoreApp,Version=v6.0) / win-x64. Pr
oject MyProject.Common supports: net6.0-windows10.0.19041 (.NETCoreApp,Version=v6.0)
PathToMyProject\myProject.csproj : error NU1201:
Project MyProject.Common is not compatible with net6.0-maccatalyst15.2 (.NETCoreApp,Version=v6.0) / win10-arm64
. Project MyProject.Common supports: net6.0-windows10.0.19041 (.NETCoreApp,Version=v6.0)
PathToMyProject\myProject.csproj : error NU1201:
Project MyProject.Common is not compatible with net6.0-maccatalyst15.2 (.NETCoreApp,Version=v6.0) / win10-x64.
Project MyProject.Common supports: net6.0-windows10.0.19041 (.NETCoreApp,Version=v6.0)
PathToMyProject\myProject.csproj : error NU1201:
Project MyProject.Common is not compatible with net6.0-maccatalyst15.2 (.NETCoreApp,Version=v6.0) / win10-x86.
Project MyProject.Common supports: net6.0-windows10.0.19041 (.NETCoreApp,Version=v6.0)
看来主要问题是包降级和兼容性net6.0-maccatalyst15.2。有谁知道如何解决这个问题吗?
更新
我创建了一个新的 MAUI Blazor 应用程序并将我的所有文件都移了过来。这解决了一些问题(我的项目太旧了,模板已经收到了几次更新)。现在我遇到了以下几个错误。
Project MyProject.Common is not compatible with net6.0-maccatalyst15.2
上面提到的是.net 6的一个通用库,它只包含简单的DTO。当我为 iOS、Android 和 MacOS 构建应用程序时,一切都很好。但是,当我尝试制作 windows 可安装工件时,我遇到了这个问题。
更新 2
我需要将 class 库更改为 MAUI 库。
这是一个分为两部分的答案。首先我的 MAUI 模板很旧,所以我创建了一个新项目并复制了文件。其次,我需要使用一个 MAUI 库作为我的常用库。
我正在尝试为 windows 创建我的 MAUI Blazor 应用程序的可安装工件。从我的所有研究中,我要 运行 使用 MSBuild 的以下命令。
"C:\Program Files\Microsoft Visual Studio22\Preview\MSBuild\Current\Bin\msbuild" /restore /t:Publish /p:TargetFramework=net6.0-windows10.0.19041 /p:configuration=release /p:GenerateAppxPackageOnBuild=true /p:AppxPackageSigningEnabled=true /p:PackageCertificateThumbprint="{myThumbPrint}" /p:PackageCertificatePassword="{myPassword}"
但是,当我 运行 命令时,我得到一长串错误。 (我可以通过 Visual Studio 毫无问题地调试应用程序)
Build FAILED.
"PathToMyProject\myProject.csproj" (Restore target)
(1) ->
(Restore target) ->
PathToMyProject\myProject.csproj : error NU1605:
Detected package downgrade: Microsoft.Graphics.Win2D from 1.0.0.30 to 1.0.0.29-preview3. Reference the package directly
from the project to select a different version.
PathToMyProject\myProject.csproj : error NU1605: S
DS2.JobScheduler.Client -> Microsoft.Maui.Dependencies 6.0.200-preview.13.2865 -> Microsoft.Graphics.Win2D (>= 1.0.0.30
)
PathToMyProject\myProject.csproj : error NU1605: S
DS2.JobScheduler.Client -> Microsoft.Graphics.Win2D (>= 1.0.0.29-preview3)
PathToMyProject\myProject.csproj : error NU1605:
Detected package downgrade: Microsoft.WindowsAppSDK from 1.0.0 to 1.0.0-preview3. Reference the package directly from t
he project to select a different version.
PathToMyProject\myProject.csproj : error NU1605: S
DS2.JobScheduler.Client -> Microsoft.Maui.Dependencies 6.0.200-preview.13.2865 -> Microsoft.WindowsAppSDK (>= 1.0.0)
PathToMyProject\myProject.csproj : error NU1605: S
DS2.JobScheduler.Client -> Microsoft.WindowsAppSDK (>= 1.0.0-preview3)
PathToMyProject\myProject.csproj : error NU1605:
Detected package downgrade: Microsoft.Graphics.Win2D from 1.0.0.30 to 1.0.0.29-preview3. Reference the package directly
from the project to select a different version.
PathToMyProject\myProject.csproj : error NU1605: S
DS2.JobScheduler.Client -> Microsoft.AspNetCore.Components.WebView.Maui 6.0.200-preview.13.2865 -> Microsoft.Graphics.W
in2D (>= 1.0.0.30)
PathToMyProject\myProject.csproj : error NU1605: S
DS2.JobScheduler.Client -> Microsoft.Graphics.Win2D (>= 1.0.0.29-preview3)
PathToMyProject\myProject.csproj : error NU1605:
Detected package downgrade: Microsoft.WindowsAppSDK from 1.0.0 to 1.0.0-preview3. Reference the package directly from t
he project to select a different version.
PathToMyProject\myProject.csproj : error NU1605: S
DS2.JobScheduler.Client -> Microsoft.AspNetCore.Components.WebView.Maui 6.0.200-preview.13.2865 -> Microsoft.WindowsApp
SDK (>= 1.0.0)
PathToMyProject\myProject.csproj : error NU1605: S
DS2.JobScheduler.Client -> Microsoft.WindowsAppSDK (>= 1.0.0-preview3)
PathToMyProject\myProject.csproj : error NU1201:
Project MyProject.Common is not compatible with net6.0-android31.0 (.NETCoreApp,Version=v6.0). Project SDS2.Job
Scheduler.Common supports: net6.0-windows10.0.19041 (.NETCoreApp,Version=v6.0)
PathToMyProject\myProject.csproj : error NU1201:
Project MyProject.Common is not compatible with net6.0-ios15.2 (.NETCoreApp,Version=v6.0). Project SDS2.JobSche
duler.Common supports: net6.0-windows10.0.19041 (.NETCoreApp,Version=v6.0)
PathToMyProject\myProject.csproj : error NU1201:
Project MyProject.Common is not compatible with net6.0-maccatalyst15.2 (.NETCoreApp,Version=v6.0). Project SDS2
.JobScheduler.Common supports: net6.0-windows10.0.19041 (.NETCoreApp,Version=v6.0)
PathToMyProject\myProject.csproj : error NU1201:
Project MyProject.Common is not compatible with net6.0-android31.0 (.NETCoreApp,Version=v6.0) / win-x64. Projec
t MyProject.Common supports: net6.0-windows10.0.19041 (.NETCoreApp,Version=v6.0)
PathToMyProject\myProject.csproj : error NU1201:
Project MyProject.Common is not compatible with net6.0-android31.0 (.NETCoreApp,Version=v6.0) / win10-arm64. Pr
oject MyProject.Common supports: net6.0-windows10.0.19041 (.NETCoreApp,Version=v6.0)
PathToMyProject\myProject.csproj : error NU1201:
Project MyProject.Common is not compatible with net6.0-android31.0 (.NETCoreApp,Version=v6.0) / win10-x64. Proj
ect MyProject.Common supports: net6.0-windows10.0.19041 (.NETCoreApp,Version=v6.0)
PathToMyProject\myProject.csproj : error NU1201:
Project MyProject.Common is not compatible with net6.0-android31.0 (.NETCoreApp,Version=v6.0) / win10-x86. Proj
ect MyProject.Common supports: net6.0-windows10.0.19041 (.NETCoreApp,Version=v6.0)
PathToMyProject\myProject.csproj : error NU1201:
Project MyProject.Common is not compatible with net6.0-ios15.2 (.NETCoreApp,Version=v6.0) / win-x64. Project SD
S2.JobScheduler.Common supports: net6.0-windows10.0.19041 (.NETCoreApp,Version=v6.0)
PathToMyProject\myProject.csproj : error NU1201:
Project MyProject.Common is not compatible with net6.0-ios15.2 (.NETCoreApp,Version=v6.0) / win10-arm64. Projec
t MyProject.Common supports: net6.0-windows10.0.19041 (.NETCoreApp,Version=v6.0)
PathToMyProject\myProject.csproj : error NU1201:
Project MyProject.Common is not compatible with net6.0-ios15.2 (.NETCoreApp,Version=v6.0) / win10-x64. Project
MyProject.Common supports: net6.0-windows10.0.19041 (.NETCoreApp,Version=v6.0)
PathToMyProject\myProject.csproj : error NU1201:
Project MyProject.Common is not compatible with net6.0-ios15.2 (.NETCoreApp,Version=v6.0) / win10-x86. Project
MyProject.Common supports: net6.0-windows10.0.19041 (.NETCoreApp,Version=v6.0)
PathToMyProject\myProject.csproj : error NU1201:
Project MyProject.Common is not compatible with net6.0-maccatalyst15.2 (.NETCoreApp,Version=v6.0) / win-x64. Pr
oject MyProject.Common supports: net6.0-windows10.0.19041 (.NETCoreApp,Version=v6.0)
PathToMyProject\myProject.csproj : error NU1201:
Project MyProject.Common is not compatible with net6.0-maccatalyst15.2 (.NETCoreApp,Version=v6.0) / win10-arm64
. Project MyProject.Common supports: net6.0-windows10.0.19041 (.NETCoreApp,Version=v6.0)
PathToMyProject\myProject.csproj : error NU1201:
Project MyProject.Common is not compatible with net6.0-maccatalyst15.2 (.NETCoreApp,Version=v6.0) / win10-x64.
Project MyProject.Common supports: net6.0-windows10.0.19041 (.NETCoreApp,Version=v6.0)
PathToMyProject\myProject.csproj : error NU1201:
Project MyProject.Common is not compatible with net6.0-maccatalyst15.2 (.NETCoreApp,Version=v6.0) / win10-x86.
Project MyProject.Common supports: net6.0-windows10.0.19041 (.NETCoreApp,Version=v6.0)
看来主要问题是包降级和兼容性net6.0-maccatalyst15.2。有谁知道如何解决这个问题吗?
更新
我创建了一个新的 MAUI Blazor 应用程序并将我的所有文件都移了过来。这解决了一些问题(我的项目太旧了,模板已经收到了几次更新)。现在我遇到了以下几个错误。
Project MyProject.Common is not compatible with net6.0-maccatalyst15.2
上面提到的是.net 6的一个通用库,它只包含简单的DTO。当我为 iOS、Android 和 MacOS 构建应用程序时,一切都很好。但是,当我尝试制作 windows 可安装工件时,我遇到了这个问题。
更新 2
我需要将 class 库更改为 MAUI 库。
这是一个分为两部分的答案。首先我的 MAUI 模板很旧,所以我创建了一个新项目并复制了文件。其次,我需要使用一个 MAUI 库作为我的常用库。