Clickonce GenerateApplicationManifest MSB3171 "... um ein Programm mit einem falschen Format zu laden" mit nativen DLLs
Posted: 20 Mar 2025, 11:44
Ich habe das folgende einfache Projekt: < /p>
Schritt:
> montagType .
Ausführen eines Builds funktioniert:
Code: Select all
using ImageMagick;
using SkiaSharp;
using System;
namespace ConsoleApp1
{
public class Program
{
public static void Main(string[] args)
{
MagickImageInfo info = new MagickImageInfo();
info.Read("photo.jpg");
Console.WriteLine($"Magick.NET: {info.Width}x{info.Height}px");
var image = SKImage.FromEncodedData(@"photo.jpg");
var bm = SKBitmap.FromImage(image);
Console.WriteLine($"SkiaSharp: {bm.Width}x{bm.Height}px");
}
}
}
< /code>
< /code>
Debug
AnyCPU
{4965314B-8FB0-448D-93EF-804B3B4873BA}
Exe
ConsoleApp1
ConsoleApp1
v4.8
512
true
true
false
C:\path\to\published-clickonce-release\
true
Disk
false
Foreground
7
Days
false
false
true
8
1.2.3.%2a
false
true
true
AnyCPU
true
full
false
bin\Debug\
DEBUG;TRACE
prompt
4
AnyCPU
pdbonly
true
bin\Release\
TRACE
prompt
4
true
bin\x64\Debug\
DEBUG;TRACE
full
x64
7.3
prompt
true
bin\x64\Release\
TRACE
true
pdbonly
x64
7.3
prompt
true
false
http://timestamp.digicert.com
false
xxx
LocalIntranet
true
..\packages\Magick.NET-Q16-HDRI-x64.14.2.0\lib\netstandard20\Magick.NET-Q16-HDRI-x64.dll
..\packages\Magick.NET.Core.14.2.0\lib\netstandard20\Magick.NET.Core.dll
..\packages\SkiaSharp.2.88.9\lib\net462\SkiaSharp.dll
..\packages\System.Buffers.4.5.1\lib\net461\System.Buffers.dll
..\packages\System.Memory.4.5.5\lib\net461\System.Memory.dll
..\packages\System.Numerics.Vectors.4.5.0\lib\net46\System.Numerics.Vectors.dll
..\packages\System.Runtime.CompilerServices.Unsafe.4.5.3\lib\net461\System.Runtime.CompilerServices.Unsafe.dll
PreserveNewest
PreserveNewest
False
Microsoft .NET Framework 4.8 %28x86 and x64%29
true
False
.NET Framework 3.5 SP1
false
This project references NuGet package(s) that are missing on this computer. Use NuGet Package Restore to download them. For more information, see http://go.microsoft.com/fwlink/?LinkID=322105. The missing file is {0}.
< /code>
I can publish and sign this project successfully directly with Visual Studio 2022 using the Signing and Publish section in the project settings.
I have to automate that process with MSBuild tasks (without using Visualn Studio manually), especially the GenerateApplicationManifest
Code: Select all
.
ConsoleApp1.exe
$(ExecutableFilename).config
$(ExecutableFilename).manifest
$(ExecutableFilename)
Native
Install
%(RecursiveDir)%(Filename)%(Extension)
Native
Install
%(RecursiveDir)%(Filename)%(Extension)
Native
Install
%(RecursiveDir)%(Filename)%(Extension)
Native
Install
%(RecursiveDir)%(Filename)%(Extension)
< /code>
I learned that I can mark some DLLs as native inside of Dependency
Ausführen eines Builds funktioniert:
Code: Select all
& "C:\Program Files\Microsoft Visual Studio\2022\Enterprise\MSBuild\Current\Bin\MSBuild.exe" .\ConsoleApp1.sln "/p:Configuration=Release;Platform=x64;ApplicationVersion=1.2.3.4;Environment=Test" "/t:Restore;Clean;Rebuild" "/verbosity:minimal"
MSBuild-Version 17.12.6+db5f6012c für .NET Framework
Wiederherzustellende Projekte werden ermittelt...
ConsoleApp1 -> C:\...\ConsoleApp1\ConsoleApp1\bin\x64\Release\ConsoleApp1.exe
< /code>
The MSBuild task to generate the manifest fails with an error MSB3171:
C:\...\ConsoleApp1\ConsoleApp1\bin\x64\Release> & "C:\Program Files\Microsoft Visual Studio\2022\Enterprise\MSBuild\Current\Bin\MSBuild.exe" ./ClickOncePublishment.msbuild /t:GenerateManifest /property:AssemblyVersion=1.2.3.4 /property:DeploymentUrl=\\path\to\somewhere /property:Product="Acme-Client 64-bit" /property:Platform=x64
MSBuild-Version 17.12.6+db5f6012c für .NET Framework
Der Buildvorgang wurde am 26.11.2024 10:18:00 gestartet.
Die Erstellung des Projekts "C:\...\ConsoleApp1\ConsoleApp1\bin\x64\Release\ClickOncePublishment.msbuild" ist abgeschlossen, GenerateManifest Ziel(e)
-- FEHLER.
Fehler beim Buildvorgang.
"C:\...\ConsoleApp1\ConsoleApp1\bin\x64\Release\ClickOncePublishment.msbuild" (GenerateManifest Ziel) (1) ->
(GenerateManifest Ziel) ->
C:\...\ConsoleApp1\ConsoleApp1\bin\x64\Release\ClickOncePublishment.msbuild(49,5): error MSB3171: [url=viewtopic.php?t=15738]Problem[/url] beim Generieren des Manifests. Die Datei oder Assembly "C:\...\ConsoleApp1\ConsoleApp1\bin\x64\Release\x64\libSkiaSharp.dll" oder eine Abhängigkeit davon wurde nicht gefunden. Es wurde versucht, eine Datei mit einem falschen Format zu laden.
C:\...\ConsoleApp1\ConsoleApp1\bin\x64\Release\ClickOncePublishment.msbuild(49,5): error MSB3171: [url=viewtopic.php?t=15738]Problem[/url] beim Generieren des Manifests. Die Datei oder Assembly "C:\...\ConsoleApp1\ConsoleApp1\bin\x64\Release\Magick.Native-Q16-HDRI-x64.dll" oder eine Abhängigkeit davon wurde nicht gefunden. Es wurde versucht, eine Datei mit einem falschen Format zu laden.
C:\...\ConsoleApp1\ConsoleApp1\bin\x64\Release\ClickOncePublishment.msbuild(49,5): error MSB3171: [url=viewtopic.php?t=15738]Problem[/url] beim Generieren des Manifests. Die Datei oder Assembly "C:\...\ConsoleApp1\ConsoleApp1\bin\x64\Release\arm64\libSkiaSharp.dll" oder eine Abhängigkeit davon wurde nicht gefunden. Es wurde versucht, eine Datei mit einem falschen Format zu laden.
C:\...\ConsoleApp1\ConsoleApp1\bin\x64\Release\ClickOncePublishment.msbuild(49,5): error MSB3171: [url=viewtopic.php?t=15738]Problem[/url] beim Generieren des Manifests. Die Datei oder Assembly "C:\...\ConsoleApp1\ConsoleApp1\bin\x64\Release\x86\libSkiaSharp.dll" oder eine Abhängigkeit davon wurde nicht gefunden. Es wurde versucht, eine Datei mit einem falschen Format zu laden.
0 Warnung(en)
4 Fehler
< /code>
(english: "Could not load file or assembly '*.dll' or one of its dependencies. An attempt was made to load a program with an incorrect format.")
I don't see a [url=viewtopic.php?t=15738]problem[/url] with a specific DLL, because it doesn't work with multiple different DLLs from different projects. The manifest generation works from Visual Studio. I am running the publishing step on the same machine as the MSBuild task. The DLL itself is not corrupted and does its job. Putting non-native DLLs into the manifest works. Marking the native DLLs as "Managed" does not work either.
The correct manifest would be:
niWdT26A895yuMleQfgsBQBSOtv3UM5lth/uruyHma0=
d0+KN/+66+8C8h1R7O0fU62zOnIL7ae8X4C1ACHMm1Y=
32+oirD9Nbv+ozVgJIj6gYZ5Pz/ihw4gNdg4Wscgzm4=
5ww8h2/H/LM6NXOEMQdkkOrkfTSBM7rQgI1qv1pxYFY=
...