Execute build script after build but before nuget packaging

ctstone's Avatar

ctstone

19 Aug, 2014 04:10 PM

I have a post-build script that strongname-signs my compiled assembly. However, I can see that this script is being executed after the nuget artifact is packaged which means the dll in the nuget package stays unsigned. Is there any way to make sure my post-build script executes immediately after the build?

Or do I need to disable 'Package NuGet projects' and incorporate that action directly into my post-build script? I suppose unpacking + sign + repacking the the nuget package would also work, but is not ideal.

  1. Support Staff 1 Posted by Feodor Fitsner on 19 Aug, 2014 04:52 PM

    Feodor Fitsner's Avatar

    I would incorporate signing logic into post build target inside csproj file. Otherwise, yes, you can disable auto-packaging and call nuget pack command from your after build script.

    - Feodor

  2. 2 Posted by ctstone on 19 Aug, 2014 08:40 PM

    ctstone's Avatar

    Thanks!

    Here's what I did in case anyone is curious:

    Environment Variables
    StrongNameKey= secure string containing base64 encoded key bytes
    StrongNameKeyPath= "c:\keys\mykey.snk"

    Install Script

    mkdir ([io.path]::GetDirectoryName($env:StrongNameKeyPath)) | out-null
    [IO.File]::WriteAllBytes($env:StrongNameKeyPath, [Convert]::FromBase64String($env:StrongNameKey))

    .csproj

      <PropertyGroup Condition=" '$(APPVEYOR)' == 'True' ">
        <SignAssembly>true</SignAssembly>
        <AssemblyOriginatorKeyFile>$(StrongNameKeyPath)</AssemblyOriginatorKeyFile>
      </PropertyGroup>
      <PropertyGroup Condition=" '$(APPVEYOR)' == '' ">
        <SignAssembly>true</SignAssembly>
        <DelaySign>true</DelaySign>
        <AssemblyOriginatorKeyFile>..\path\to\publickey.snk</AssemblyOriginatorKeyFile>
      </PropertyGroup>
    

    And nothing at all in the post-build script.

  3. Support Staff 3 Posted by Feodor Fitsner on 19 Aug, 2014 08:42 PM

    Feodor Fitsner's Avatar

    Awesome, thanks for sharing the solution!

  4. Ilya Finkelshteyn closed this discussion on 25 Aug, 2018 01:47 AM.

Comments are currently closed for this discussion. You can start a new one.

Keyboard shortcuts

Generic

? Show this help
ESC Blurs the current field

Comment Form

r Focus the comment reply box
^ + ↩ Submit the comment

You can use Command ⌘ instead of Control ^ on Mac

 

01 Oct, 2024 04:27 PM
26 Sep, 2024 03:49 PM
26 Sep, 2024 09:02 AM
25 Sep, 2024 07:07 PM
24 Sep, 2024 08:39 PM
24 Sep, 2024 06:47 AM