Comments (5)
I think you'll have a lot more luck with v3.3.0.
In your project file you need to remove the target imports and use your own custom one to just sign DYMO.Connect.SDK
.
- Install the latest NuGet package (https://www.nuget.org/packages/Brutal.Dev.StrongNameSigner/3.3.0).
- Remove the following lines from your
.csproj
file:
<Error Condition="!Exists('..\packages\Brutal.Dev.StrongNameSigner.X.Y.Z\build\Brutal.Dev.StrongNameSigner.targets')" Text="$([System.String]::Format('$(ErrorText)', '..\packages\Brutal.Dev.StrongNameSigner.X.Y.Z\build\Brutal.Dev.StrongNameSigner.targets'))" />
...
<Import Project="..\packages\Brutal.Dev.StrongNameSigner.X.Y.Z\build\Brutal.Dev.StrongNameSigner.targets" Condition="Exists('..\packages\Brutal.Dev.StrongNameSigner.X.Y.Z\build\Brutal.Dev.StrongNameSigner.targets')" />
- Add the following into your
.csproj
file inside the<Project>
element:
<Target Name="BeforeCompile">
<Exec ContinueOnError="false"
Command=""..\packages\Brutal.Dev.StrongNameSigner.3.3.0\build\StrongNameSigner.Console.exe" -in "..\packages\DYMO.Connect.SDK.1.4.3.37" -k UnprotectedKey.snk" />
</Target>
- Reload your project and build.
In your test project this builds just fine with no errors/warnings:
Rebuild started...
1>------ Rebuild All started: Project: DYMOSDKSampleForSNS, Configuration: Debug Any CPU ------
1> -------------------------------------------------------------------
1> ---- Brutal Developer .NET Assembly Strong-Name Signer 3.3.0.0 ----
1> -------------------------------------------------------------------
1> Console application to sign .NET assemblies with a strong-name key and fix assembly references.
1> 1. Loading assemblies...
1> Unsupported assembly 'C:\DYMOSDKSampleForSNS\packages\DYMO.Connect.SDK.1.4.3.37\Build\DYMOLib\x64\libdymobarcode.dll': Format of the executable (.exe) or library (.dll) is invalid.
1> Unsupported assembly 'C:\DYMOSDKSampleForSNS\packages\DYMO.Connect.SDK.1.4.3.37\Build\DYMOLib\x64\usps4cb.dll': Format of the executable (.exe) or library (.dll) is invalid.
1> Unsupported assembly 'C:\DYMOSDKSampleForSNS\packages\DYMO.Connect.SDK.1.4.3.37\Build\DYMOLib\x86\libdymobarcode.dll': Format of the executable (.exe) or library (.dll) is invalid.
1> Unsupported assembly 'C:\DYMOSDKSampleForSNS\packages\DYMO.Connect.SDK.1.4.3.37\Build\DYMOLib\x86\usps4cb.dll': Format of the executable (.exe) or library (.dll) is invalid.
1> 2. Checking assembly references...
1> Checking assembly references in 'C:\DYMOSDKSampleForSNS\packages\DYMO.Connect.SDK.1.4.3.37\Build\DYMOLib\DYMO.Common.dll'.
1> Checking assembly references in 'C:\DYMOSDKSampleForSNS\packages\DYMO.Connect.SDK.1.4.3.37\Build\DYMOLib\DYMO.CrossPlatform.Common.dll'.
1> Checking assembly references in 'C:\DYMOSDKSampleForSNS\packages\DYMO.Connect.SDK.1.4.3.37\Build\DYMOLib\DYMO.LabelAPI.dll'.
1> Checking assembly references in 'C:\DYMOSDKSampleForSNS\packages\DYMO.Connect.SDK.1.4.3.37\Build\DYMOLib\OSX\platspec\DYMO.CrossPlatform.Common.PlatformSpecific.dll'.
1> Checking assembly references in 'C:\DYMOSDKSampleForSNS\packages\DYMO.Connect.SDK.1.4.3.37\Build\DYMOLib\OSX\platspec\DYMO.LabelAPI.PlatformSpecific.dll'.
1> Checking assembly references in 'C:\DYMOSDKSampleForSNS\packages\DYMO.Connect.SDK.1.4.3.37\Build\DYMOLib\Win\DYMO.CrossPlatform.Common.PlatformSpecific.dll'.
1> Checking assembly references in 'C:\DYMOSDKSampleForSNS\packages\DYMO.Connect.SDK.1.4.3.37\Build\DYMOLib\Win\DYMO.LabelAPI.PlatformSpecific.dll'.
1> Checking assembly references in 'C:\DYMOSDKSampleForSNS\packages\DYMO.Connect.SDK.1.4.3.37\Build\DYMOLib\x64\DYMOPrinting.dll'.
1> Checking assembly references in 'C:\DYMOSDKSampleForSNS\packages\DYMO.Connect.SDK.1.4.3.37\Build\DYMOLib\x64\LW5xxCommunicationLibrary.dll'.
1> Checking assembly references in 'C:\DYMOSDKSampleForSNS\packages\DYMO.Connect.SDK.1.4.3.37\Build\DYMOLib\x64\PrintingSupportLibrary.dll'.
1> Checking assembly references in 'C:\DYMOSDKSampleForSNS\packages\DYMO.Connect.SDK.1.4.3.37\Build\DYMOLib\x86\DYMOPrinting.dll'.
1> Checking assembly references in 'C:\DYMOSDKSampleForSNS\packages\DYMO.Connect.SDK.1.4.3.37\Build\DYMOLib\x86\LW5xxCommunicationLibrary.dll'.
1> Checking assembly references in 'C:\DYMOSDKSampleForSNS\packages\DYMO.Connect.SDK.1.4.3.37\Build\DYMOLib\x86\PrintingSupportLibrary.dll'.
1> Checking assembly references in 'C:\DYMOSDKSampleForSNS\packages\DYMO.Connect.SDK.1.4.3.37\lib\netstandard2.0\DymoSDK.dll'.
1> 3. Strong-name unsigned assemblies...
1> Signing assembly 'C:\DYMOSDKSampleForSNS\packages\DYMO.Connect.SDK.1.4.3.37\Build\DYMOLib\DYMO.CrossPlatform.Common.dll'.
1> Signing assembly 'C:\DYMOSDKSampleForSNS\packages\DYMO.Connect.SDK.1.4.3.37\Build\DYMOLib\DYMO.LabelAPI.dll'.
1> Signing assembly 'C:\DYMOSDKSampleForSNS\packages\DYMO.Connect.SDK.1.4.3.37\Build\DYMOLib\OSX\platspec\DYMO.CrossPlatform.Common.PlatformSpecific.dll'.
1> Signing assembly 'C:\DYMOSDKSampleForSNS\packages\DYMO.Connect.SDK.1.4.3.37\Build\DYMOLib\OSX\platspec\DYMO.LabelAPI.PlatformSpecific.dll'.
1> Signing assembly 'C:\DYMOSDKSampleForSNS\packages\DYMO.Connect.SDK.1.4.3.37\Build\DYMOLib\Win\DYMO.CrossPlatform.Common.PlatformSpecific.dll'.
1> Signing assembly 'C:\DYMOSDKSampleForSNS\packages\DYMO.Connect.SDK.1.4.3.37\Build\DYMOLib\Win\DYMO.LabelAPI.PlatformSpecific.dll'.
1> Signing assembly 'C:\DYMOSDKSampleForSNS\packages\DYMO.Connect.SDK.1.4.3.37\Build\DYMOLib\x64\DYMOPrinting.dll'.
1> Signing assembly 'C:\DYMOSDKSampleForSNS\packages\DYMO.Connect.SDK.1.4.3.37\Build\DYMOLib\x86\DYMOPrinting.dll'.
1> Signing assembly 'C:\DYMOSDKSampleForSNS\packages\DYMO.Connect.SDK.1.4.3.37\lib\netstandard2.0\DymoSDK.dll'.
1> 4. Fix InternalVisibleToAttribute references...
1> Fixing DYMO.LabelAPI.PlatformSpecific friend reference in assembly 'C:\DYMOSDKSampleForSNS\packages\DYMO.Connect.SDK.1.4.3.37\Build\DYMOLib\DYMO.LabelAPI.dll'.
1> 5. Fix BAML references...
1> Replacing BAML entry in assembly 'C:\DYMOSDKSampleForSNS\packages\DYMO.Connect.SDK.1.4.3.37\Build\DYMOLib\Win\DYMO.LabelAPI.PlatformSpecific.dll'.
1> 6. Save assembly changes...
1> Saving changes to assembly 'C:\DYMOSDKSampleForSNS\packages\DYMO.Connect.SDK.1.4.3.37\Build\DYMOLib\DYMO.CrossPlatform.Common.dll'.
1> Saving changes to assembly 'C:\DYMOSDKSampleForSNS\packages\DYMO.Connect.SDK.1.4.3.37\Build\DYMOLib\DYMO.LabelAPI.dll'.
1> Saving changes to assembly 'C:\DYMOSDKSampleForSNS\packages\DYMO.Connect.SDK.1.4.3.37\Build\DYMOLib\OSX\platspec\DYMO.CrossPlatform.Common.PlatformSpecific.dll'.
1> Saving changes to assembly 'C:\DYMOSDKSampleForSNS\packages\DYMO.Connect.SDK.1.4.3.37\Build\DYMOLib\OSX\platspec\DYMO.LabelAPI.PlatformSpecific.dll'.
1> Saving changes to assembly 'C:\DYMOSDKSampleForSNS\packages\DYMO.Connect.SDK.1.4.3.37\Build\DYMOLib\Win\DYMO.CrossPlatform.Common.PlatformSpecific.dll'.
1> Saving changes to assembly 'C:\DYMOSDKSampleForSNS\packages\DYMO.Connect.SDK.1.4.3.37\Build\DYMOLib\Win\DYMO.LabelAPI.PlatformSpecific.dll'.
1> Saving changes to assembly 'C:\DYMOSDKSampleForSNS\packages\DYMO.Connect.SDK.1.4.3.37\Build\DYMOLib\x64\DYMOPrinting.dll'.
1> Failed to save assembly 'C:\DYMOSDKSampleForSNS\packages\DYMO.Connect.SDK.1.4.3.37\Build\DYMOLib\x64\DYMOPrinting.dll': Writing mixed-mode assemblies is not supported
1> Saving changes to assembly 'C:\DYMOSDKSampleForSNS\packages\DYMO.Connect.SDK.1.4.3.37\Build\DYMOLib\x86\DYMOPrinting.dll'.
1> Failed to save assembly 'C:\DYMOSDKSampleForSNS\packages\DYMO.Connect.SDK.1.4.3.37\Build\DYMOLib\x86\DYMOPrinting.dll': Writing mixed-mode assemblies is not supported
1> Saving changes to assembly 'C:\DYMOSDKSampleForSNS\packages\DYMO.Connect.SDK.1.4.3.37\lib\netstandard2.0\DymoSDK.dll'.
1> 7. Cleanup...
1> DYMOSDKSampleForSNS -> C:\DYMOSDKSampleForSNS\DYMOSDKSampleForSNS\bin\Debug\DYMOSDKSampleForSNS.dll
========== Rebuild All: 1 succeeded, 0 failed, 0 skipped ==========
========== Elapsed 00:02.623 ==========
You can note the mixed-mode assemblies that are not supported, those are likely the ones being dynamically loaded. You can test this out in your real project and see if it works.
from strongnamesigner.
Please provide the log output from the signing process. You can also provide the log output when using the user interface/console application for the assemblies that get ignored (mixed-mode or native I suspect).
Do you have a sample project or is it just a basic project that brings in the DYMO.Connect.SDK NuGet package?
I've mostly already worked around my problem by not signing my class library project
Why not just leave things unsigned, is there is a specific reason you need to actually strong-name sign your project?
Unsigned assemblies can use signed assemblies but not the other way around (which is what this tool was created for). If you do not need to sign your own stuff then don't worry about trying to sign others.
from strongnamesigner.
I have made a quick VS2022 sample project for it and attached it.
(but I had to exclude the actual packages from the zip because of upload size limitations, but they are fresh from the store)
Just a basic .NET Framework class library targeting .NET Framework 4.7.2 with the "DYMO.Connect.SDK" (+ dependencies) and "Brutal.Dev.StrongNameSigner" NuGet packages added, and maybe some short code to initialize the SDK.
The output directory looks complete like that and reproduces the error in my application.
The log from the build process (including SNS notifications) is this - is this log sufficient or did I miss anything?:
------ Build started: Project: DYMOSDKSampleForSNS, Configuration: Debug Any CPU ------
-- Starting Brutal Developer .NET Assembly Strong-Name Signer Task --
Adding 'C:\Users\user\Desktop\Projects\DYMOSDKSampleForSNS\packages\DYMO.Connect.SDK.1.4.3.37\lib\netstandard2.0\DymoSDK.dll' for processing.
Adding 'C:\Users\user\Desktop\Projects\DYMOSDKSampleForSNS\packages\SkiaSharp.1.68.0\lib\net45\SkiaSharp.dll' for processing.
Checking assembly references in 'C:\Users\user\Desktop\Projects\DYMOSDKSampleForSNS\packages\DYMO.Connect.SDK.1.4.3.37\lib\netstandard2.0\DymoSDK.dll'.
Checking assembly references in 'C:\Users\user\Desktop\Projects\DYMOSDKSampleForSNS\packages\SkiaSharp.1.68.0\lib\net45\SkiaSharp.dll'.
-- Finished Brutal Developer .NET Assembly Strong-Name Signer Task in 00:00:00.7031904 --
DYMOSDKSampleForSNS -> C:\Users\user\Desktop\Projects\DYMOSDKSampleForSNS\DYMOSDKSampleForSNS\bin\Debug\DYMOSDKSampleForSNS.dll
========== Build: 1 succeeded, 0 failed, 0 up-to-date, 0 skipped ==========
========== Elapsed 00:01,503 ==========
It looks like the StrongNameSigner is not even doing that much there.
(the 2 DLLs that it checks are already signed by default if the SDK NuGet package is left unmodified)
But the problematic DLLs seem to be in the "Build" directory of the "DYMO.Connect.SDK" package.
(and those DLLs also are part of the dependency tree of the SDK DLLs. And they also flow into the output directory)
E.g. "DYMO.CrossPlatform.Common.dll".
(DYMO.CrossPlatform.Common, Version=1.4.3.37, Culture=neutral, PublicKeyToken=null)
As far as I can see (with ILspy), the signed "DymoSDK.dll" references it.
(DymoSDK, Version=1.0.0.0, Culture=neutral, PublicKeyToken=8cbe8a3c50c5633e)
Thats what actually is inside the Build directory, but we would need to sign it and fix the reference inside DymoSDK.dll to also point at that signed assembly for my application to not complain because my signed DLL is using unsigned dependencies.
I'm not sure how you could reproduce the actual error with this sample project as I'm actually using the class library as an interop "addin" inside Microsoft Dynamics NAV and talk to the DLL using C/AL code.. Not sure if the same error would appear when trying anything (e.g. call GetPrinters()) from a e.g. WinForms app thats using the DLL.
In my opinion it would be OK to "re-sign" DymoSDK.dll with a new key if necessary to fix the unsigned references.
(but the tool would first have to try to do something with DYMO.CrossPlatform.Common.dll?)
Let me know if you need more information.
Edit
Added code block around the log to make it more readable.
from strongnamesigner.
I've overlooked your additional response in the quote box:
Why not just leave things unsigned, is there is a specific reason you need to actually strong-name sign your project?
Unsigned assemblies can use signed assemblies but not the other way around (which is what this tool was created for). If you do not need to sign your own stuff then don't worry about trying to sign others.
Thats what I'm doing as a workaround for now. Not sign my library = no errors.
Its just usually best practise for NAV DLLs to strong name sign them.
(otherwise there may be issues with deployment later on)
And I never had to not do it because of a 3rd party library. The DYMO SDK may be the first one.
Edit
Added a reason to adhere to the best practises in my case in brackets. But that would require using the signed dependency in my signed wrapper DLL. And it's dependencies also all need to be signed, but the SDK doesn't come like that from the vendor.
Somehow their signed main assembly is referencing some unsigned assemblies and no one ever noticed the error internally..
(if I just sign the unsigned assemblies - if it works - my app would no longer find the signed assembly at run time, so the references need to be correct as well)
Thats how I come across StrongNameSigner after reading a post with ildasm/ilasm commands to manually fix stuff like this.
It might not be a bug, but rather 1-2 new features to catch more of those DLLs (also in the VS build task as I'm not using the tools manually?) and also rewrite signed assemblies to fix references to previously unsigned assemblies after signing them - but you now have an example of a bad SDK to possibly harden the tool on. Its not critical for now. But I really like the idea of one automated tool to fix all DLL strong name signing related problems ;)
from strongnamesigner.
Somehow their signed main assembly is referencing some unsigned assemblies
They are probably dynamically loading them and not referencing them.
SNS can fix all of this, but if there is no hard reference then there is no way for it to know it also needs to sign these extra assemblies. You will need to specify the list of assemblies you want to sign and will not be able to easily use the automatic build task.
I'll look into this a bit later, I'm still on vacation.
from strongnamesigner.
Related Issues (20)
- It seems not working in sdk-style project with third-part packages HOT 6
- How to consume a NuGet package with signed external references? HOT 3
- Writing mixed-mode assemblies is not supported HOT 3
- Transitive dependencies from PackageReferences are not investigated/signed HOT 3
- Use NuGet package, but no automatic signing of assemblies HOT 2
- Use NuGet package, but no automatic signing of assemblies HOT 2
- Virus Detected on Chrome when downloading StrongNameSigner_Setup.exe HOT 1
- SDK style probjects supported? HOT 4
- Failed to resolve assembly: 'mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089' HOT 12
- [Bug]: When the GUI comes across a "Unsupported PDB deleted bitset is not empty" it stops processing HOT 1
- [Feature Request]: convert the "Unsupported PDB deleted bitset is not empty" Error to a warning, so that the commandline app does not report errors HOT 2
- [Feature Request]: Can the Gui state what file has been used to sign a binary HOT 1
- [Bug]: If strongnamer is already processing a file, then do not throw an error when it tries to open it again due to parallel builds
- [Change Request]: Please change the column named `Signed` to be `StrongNamed` HOT 1
- [Feature Request]: Have a column called `DigCert` to show if this binary also has been digitally signed HOT 2
- [Bug]: Getting `Mono.Cecil.AssemblyResolutionException: Failed to resolve assembly: 'mscorlib, Version=4.0.0.0` for x86 project HOT 13
- Keyset does not exist error when using custom SNK generated from PFX file HOT 3
- Does not work with VS 2022 started with Admin rights targeting .net 4.8 framework HOT 9
- Can not get it to work with .NET Standard 2.0 Project and Nuget Packages Scrypt.NET and CSVTextFieldParser HOT 2
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from strongnamesigner.