I added the following code to my CSPROJ-File:

<Target Name="PostBuild" AfterTargets="PostBuildEvent">
   <SignFile CertificateThumbprint="{some-sha-code}" SigningTarget="$(TargetPath)" />
</Target>

It works if I build directly in Visual Studio 2019. If I try to build it via "dotnet build" I get the following error:

error MSB4062: Die Microsoft.Build.Tasks.SignFile-Aufgabe konnte nicht aus der Microsoft.Build.Tasks.Core, Version=15.1.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a-Assembly geladen werden. Stellen Sie sicher, dass die <UsingTask>-Deklaration korrekt ist, die Assembly und alle zugeh”rigen Abh„ngigkeiten verfgbar sind und die Aufgabe eine ”ffentliche Klasse enth„lt, die Microsoft.Build.Framework.ITask implementiert.

Unfortunatly the software gives me the error message in German, I didn't know how to change it. It explicitly using wrong German (meaning the wrong encoding for the Umlaute!) It says something like this:

"The […]SignFile-Task could not be loaded from assembly […]Tasks.Core, Version=15.1.0.0. Check if <UsingTask> declaration is correct and all dependencies are availabe and it should contain a task that implements […]ITask."

I didn't have a <UsingTask>-Section. The "SignFile" documentation doesn't say anyting about the UsingTask-Section either.

Has anyone got an idea how I get this to work?

PS: The reason I try to get this to work is, that our TFS is configures to use "dotnet build" and "dotnet pack" for building and deploying the dlls. I had problems on the TFS with the "pack" if I didn't use "dotnet" but "VSBUILD". It's very annoying that there isn't a build tool that just works.

0 Answers