I'm trying to publish a MAUI App for Windows machine by executing this CLI command. I followed the publish docs from this link https://learn.microsoft.com/en-us/dotnet/maui/windows/deployment/publish-unpackaged-cli?view=net-maui-8.0#publish
Executed Command:
dotnet publish -c Release -f net8.0-windows10.0.19041.0 -p:PublishSingleFile=true -p:Platform=x64 -p:WindowsPackageType=None -p:RuntimeIdentifierOverride=win10-x64 -p:WindowsAppSDKSelfContained=true
The Result:
C:\Program Files\dotnet\sdk\8.0.200\Sdks\Microsoft.NET.Sdk\targets\Microsoft.NET.ConflictResolution.targets(112,5):
error NETSDK1152: Found multiple publish output files with the same relative path: C:\...\src
\Apps\MyApp.ClientApp\obj\x64\Release\net8.0-windows10.0.19041.0\win10-x64\MsixContent\Microsoft.Web.WebView2.Core.dll, obj\x64\Release\net8.0-windows10.0.19041.0\win10-x64\R2R\Microsoft.Web.WebView2.Core.dll.
[C:\...\src\Apps\MyApp.ClientApp\MyApp.ClientApp.csproj::TargetFramework=net8.0-windows10.0.19041.0]
This problem is only available while publishing the app, but I can run and debug the application from Visual Studio 2022. How to solve this issue?
I tried many solution like adding this to my csproj file
<PropertyGroup>
<!-- creates nuget lock file packages.lock.json in the root folder, needed to cache packages in azure pipeline-->
<RestorePackagesWithLockFile>true</RestorePackagesWithLockFile>
<!-- solves build error duplicate files -->
<ErrorOnDuplicatePublishOutputFiles>false</ErrorOnDuplicatePublishOutputFiles>
</PropertyGroup>
But another error appears:
C:\Program Files\dotnet\sdk\8.0.200\Sdks\Microsoft.NET.Sdk\targets\Microsoft.NET.Publish.targets(1038,5): error MSB4018: The "GenerateBundle" task failed unexpectedly. [C:\...\src\Apps\MyApp.ClientApp\MyApp.ClientApp.csproj::TargetFramework=net8.0-windows10.0.19041.0]
C:\Program Files\dotnet\sdk\8.0.200\Sdks\Microsoft.NET.Sdk\targets\Microsoft.NET.Publish.targets(1038,5): error MSB4018: System.ArgumentException: Invalid input specification: Found entries 'obj\x64\Release\net8.0-windows10.0.19
041.0\win10-x64\R2R\Microsoft.Web.WebView2.Core.dll' and 'C:\...\src\Apps\MyApp.ClientApp\obj\x64\Release\net8.0-windows10.0.19041.0\win10-x64\MsixContent\Microsoft.Web.WebView2.Core.dll' with the sa
me BundleRelativePath 'Microsoft.Web.WebView2.Core.dll' [C:\...\src\Apps\MyApp.ClientApp\MyApp.ClientApp.csproj::TargetFramework=net8.0-windows10.0.19041.0]
C:\Program Files\dotnet\sdk\8.0.200\Sdks\Microsoft.NET.Sdk\targets\Microsoft.NET.Publish.targets(1038,5): error MSB4018: at Microsoft.NET.HostModel.Bundle.Bundler.GenerateBundle(IReadOnlyList`1 fileSpecs) [C:\...\src\Apps\MyApp.ClientApp\MyApp.ClientApp.csproj::TargetFramework=net8.0-windows10.0.19041.0]
C:\Program Files\dotnet\sdk\8.0.200\Sdks\Microsoft.NET.Sdk\targets\Microsoft.NET.Publish.targets(1038,5): error MSB4018: at Microsoft.NET.Build.Tasks.GenerateBundle.ExecuteCore() [C:\...\src\Apps\MyApp.ClientApp\MyApp.ClientApp.csproj::TargetFramework=net8.0-windows10.0.19041.0]
C:\Program Files\dotnet\sdk\8.0.200\Sdks\Microsoft.NET.Sdk\targets\Microsoft.NET.Publish.targets(1038,5): error MSB4018: at Microsoft.NET.Build.Tasks.TaskBase.Execute() [C:\...\src\Apps\MyApp.ClientApp\MyApp.ClientApp.csproj::TargetFramework=net8.0-windows10.0.19041.0]
C:\Program Files\dotnet\sdk\8.0.200\Sdks\Microsoft.NET.Sdk\targets\Microsoft.NET.Publish.targets(1038,5): error MSB4018: at Microsoft.Build.BackEnd.TaskExecutionHost.Microsoft.Build.BackEnd.ITaskExecutionHost.Execute() [C:\...\src\Apps\MyApp.ClientApp\MyApp.ClientApp.csproj::TargetFramework=net8.0-windows10.0.19041.0]
C:\Program Files\dotnet\sdk\8.0.200\Sdks\Microsoft.NET.Sdk\targets\Microsoft.NET.Publish.targets(1038,5): error MSB4018: at Microsoft.Build.BackEnd.TaskBuilder.ExecuteInstantiatedTask(ITaskExecutionHost taskExecutionHost, Tas
kLoggingContext taskLoggingContext, TaskHost taskHost, ItemBucket bucket, TaskExecutionMode howToExecuteTask) [C:\...\src\Apps\MyApp.ClientApp\MyApp.ClientApp.csproj::TargetFramework=net8.0
-windows10.0.19041.0]
Then, the error removed by adding this
<PropertyGroup>
<EnableMsixTooling>false</EnableMsixTooling>
</PropertyGroup>
But another error appears:
C:\Program Files\dotnet\sdk\8.0.200\Sdks\Microsoft.NET.Sdk\targets\Microsoft.NET.Sdk.DefaultItems.Shared.targets(213,5): error NETSDK1022: Duplicate 'Content' items were included. The .NET SDK includes 'Content' items from your
project directory by default. You can either remove these items from your project file, or set the 'EnableDefaultContentItems' property to 'false' if you want to explicitly include them in your project file. For more information
, see https://aka.ms/sdkimplicititems. The duplicate items were: 'wwwroot\favicon.png' [C:\...\src\Apps\MyApp.ClientApp\MyApp.ClientApp.csproj::TargetFramework=net8.0-windows10.0.19041.0]
Well, I removed the favicon.png from the project, who cares for now :) ... But I've got now a BUID Error ...
1>C:\Program Files\dotnet\sdk\8.0.200\Sdks\Microsoft.NET.Sdk\targets\Microsoft.NET.Sdk.FrameworkReferenceResolution.targets(491,5): error NETSDK1082: There was no runtime pack for Microsoft.NETCore.App available for the specified RuntimeIdentifier 'win10-arm'.
1>C:\Program Files\dotnet\sdk\8.0.200\Sdks\Microsoft.NET.Sdk\targets\Microsoft.NET.Sdk.FrameworkReferenceResolution.targets(491,5): error NETSDK1082: There was no runtime pack for Microsoft.NETCore.App available for the specified RuntimeIdentifier 'win10-arm-aot'.
1>C:\Program Files\dotnet\sdk\8.0.200\Sdks\Microsoft.NET.Sdk\targets\Microsoft.NET.Sdk.FrameworkReferenceResolution.targets(491,5): error NETSDK1082: There was no runtime pack for Microsoft.WindowsDesktop.App.WindowsForms available for the specified RuntimeIdentifier 'win10-arm'.
1>C:\Program Files\dotnet\sdk\8.0.200\Sdks\Microsoft.NET.Sdk\targets\Microsoft.NET.Sdk.FrameworkReferenceResolution.targets(491,5): error NETSDK1082: There was no runtime pack for Microsoft.WindowsDesktop.App.WindowsForms available for the specified RuntimeIdentifier 'win10-arm-aot'.
This is how my csproj looks at the end , and this error still exists
<PropertyGroup>
<GenerateAppInstallerFile>True</GenerateAppInstallerFile>
<AppxPackageSigningEnabled>True</AppxPackageSigningEnabled>
<PackageCertificateThumbprint>....</PackageCertificateThumbprint>
<AppxPackageSigningTimestampDigestAlgorithm>SHA256</AppxPackageSigningTimestampDigestAlgorithm>
<AppxAutoIncrementPackageRevision>True</AppxAutoIncrementPackageRevision>
<AppxSymbolPackageEnabled>False</AppxSymbolPackageEnabled>
<GenerateTestArtifacts>False</GenerateTestArtifacts>
<AppInstallerUri>C:\MeaeCareInstallers</AppInstallerUri>
<HoursBetweenUpdateChecks>0</HoursBetweenUpdateChecks>
</PropertyGroup>
<PropertyGroup>
<EnableMsixTooling>false</EnableMsixTooling>
<RestorePackagesWithLockFile>true</RestorePackagesWithLockFile>
<ErrorOnDuplicatePublishOutputFiles>false</ErrorOnDuplicatePublishOutputFiles>
</PropertyGroup>
Your help is appreciated.