rhubarb-geek-nz / SQLiteConnection

Very simple PowerShell module for creating a connection to an SQLite database.
MIT License
3 stars 1 forks source link

Missing certficate #1

Closed jdhitsolutions closed 4 months ago

jdhitsolutions commented 7 months ago

When I try to run dotnet publish SQLiteConnection.csproj --configuration Release I get an error because I don't have your certificate installed. I'm also not clear if I'm supposed to run this command before or after the package.ps1 script.

rhubarb-geek-nz commented 7 months ago

If you do have a signing certificate then provide the CertificateThumbprint property on the build line.

If you don't have a signing certificate I suggest removing the Sign target from the project.

  <Target Name="Sign" AfterTargets="Compile" Condition=" '$(Configuration)' == 'Release' AND '$(OS)' == 'Windows_NT' ">
    <ItemGroup>
        <FileToSign Include="$(IntermediateOutputPath)$(TargetFileName)" />
    </ItemGroup>
    <Message Importance="high" Text="Signing assemblies: @(FileToSign)" />
    <SignFile
          SigningTarget="@(FileToSign)"
          CertificateThumbprint="$(CertificateThumbprint)"
          TimestampUrl="http://timestamp.digicert.com"
    />
  </Target>
rhubarb-geek-nz commented 7 months ago

The package.ps1 should be called by dotnet after the publish phase

  <Target Name="Package" AfterTargets="Publish" Condition=" '$(Configuration)' == 'Release' ">
    <ItemGroup>
      <FilesToDelete Include="$(PublishDir)System.Data.SQLite.dll" />
      <FilesToDelete Include="$(PublishDir)$(AssemblyName).deps.json" />
      <FilesToDelete Include="$(PublishDir)$(AssemblyName).pdb" />
    </ItemGroup>
    <Delete Files="@(FilesToDelete)" />
    <Exec Command="dotnet tool restore" />
    <Exec Command="dotnet pwsh -c &quot;Set-Variable -Name 'ErrorActionPreference' -Value 'Stop'; if ( -not ( Get-Module -ListAvailable -Name '$(Company).PowerShellDataFile' ) ) { Install-Module -Name '$(Company).PowerShellDataFile' -Repository 'PSGallery' -Force }&quot; " />
    <Exec Command="dotnet pwsh -ExecutionPolicy Bypass -File ./package.ps1 $(AssemblyName) $(IntermediateOutputPath) $(OutDir) $(PublishDir)" />
    <RemoveDir Directories="$(PublishDir)runtimes;$(PublishDir)sqlite-netStandard20-binary" />
    <Delete Files="$(OutDir)$(PackageId).psd1" />
  </Target>

So you should not need to call it yourself

jdhitsolutions commented 7 months ago

I further modified the csproj file to invoke pwsh with -Noprofile