ghostscriptsharp icon indicating copy to clipboard operation
ghostscriptsharp copied to clipboard

gsdll32.dll isn't included when project is published (WebDeploy)

Open snebjorn opened this issue 8 years ago • 2 comments

Hi, I'm using GhostScriptSharp v1.3.1.4 and I've run into an issue when publishing a ASP.NET project.

The post-build event script only works locally.

PowerShell -NoProfile -ExecutionPolicy Bypass -Command "ls '$(SolutionDir)\packages\GhostScriptSharp.*\Tools\gsdll32.dll' | Sort -Descending | Select -First 1 | cp -Destination '$(TargetDir)'; exit 0"

So when the project is published the gsdll32.dll is missing on the server :(

However I found a solution. Inspired from https://docs.microsoft.com/en-us/aspnet/web-forms/overview/deployment/visual-studio-web-deployment/deploying-extra-files

You can add the following to the publish profile.

<Target Name="CustomCollectFiles">
    <ItemGroup>
      <_CustomFiles Include="..\packages\GhostScriptSharp.*\Tools\gsdll32.dll" />
      <FilesForPackagingFromProject Include="%(_CustomFiles.Identity)">
        <DestinationRelativePath>bin\%(Filename)%(Extension)</DestinationRelativePath>
      </FilesForPackagingFromProject>
    </ItemGroup>
  </Target>
  <PropertyGroup>
    <CopyAllFilesToSingleFolderForPackageDependsOn>
      CustomCollectFiles;
      $(CopyAllFilesToSingleFolderForPackageDependsOn);
    </CopyAllFilesToSingleFolderForPackageDependsOn>

    <CopyAllFilesToSingleFolderForMsdeployDependsOn>
      CustomCollectFiles;
      $(CopyAllFilesToSingleFolderForPackageDependsOn);
    </CopyAllFilesToSingleFolderForMsdeployDependsOn>
  </PropertyGroup>

And now the gsdll32.dll file is published along the other files. 🎉

Not sure if this somehow can be improved upon so this manual edit isn't necessary.

snebjorn avatar Apr 20 '17 14:04 snebjorn

Hi,

I've tried your approach but the file still doesn't get outputted to the bin folder. However, I can get the gsdll32.dll to be published different way than this, however, I'm still getting a file not found exception. I've even dropped it under System32 and added it to the Path.

My machine is a 64-bit Win 10, so I thought to install the 64-bit version, so I did and then started getting this error.

System.AggregateException: One or more errors occurred. ---> System.BadImageFormatException: An attempt was made to load a program with an incorrect format. (Exception from HRESULT: 0x8007000B)

So, I'm stuck now with trying to make this library to just setup. I like the simple look of it, but I've spent hours trying to make this thing to work with no luck.

ndenkha avatar May 08 '18 22:05 ndenkha

I get the Bad Image even if I manually copy the DLL under the bin folder. So, is this a problem with the Nuget that I'm installing or what?

ndenkha avatar May 08 '18 22:05 ndenkha