Closed robinbihun closed 8 years ago
Very surprising. Is there any repository from where I can clone a project to repro? I would like to help on that but it's working fine here, at work and from mono. It's possible that it's a path issue but in this case I would like to improve the error message.
Yes, let me see if i can put together a sample that mimics what we're trying to do to see if we get the same error.
Perfect, thanks.
I was able to replicate it with our folder structure -- hopefully a better error message will help us figure this out. https://github.com/robbihun/ProjBookScriptBuildError (running build\run-build.ps1 will replicate the error)
P.S. Sorry, i just realized i committed the packages folder :-/
Sounds good, I'm going to have a look at it this week end and will let you know if I find something.
I did try to reproduce but from VS and powershell I got no problem building it:
You'll find a file at src\services\packages\Projbook.1.0.6\build\Projbook.props matching this content: https://github.com/defrancea/Projbook/blob/master/resources/Projbook.props Could you please replace $(MSBuildProjectFullPath) by the full path of the csproj file of your documentation project and see if it works? I think that the MSBuild version used from your script and from your Visual Studio are different and the MSBuild one doesn't populate any value in this variable. I can change this props file in order to have fallbacks to cover your case but we need to confirm that it's actually the problem first and find which variable we can use instead in your case.
I updated the Projbook.props file and receive the same error.
I also went a step further and updated the .targets file with all of the paths that should be what msbuild generates and get the same error.
Amazing, I got a repro. The problem appear when powerhsell runs as admin. I'm definitely going to address that, thanks a lot for noticing and reporting it. In the mean time what you ca do is:
I was pretty busy with the 1.1 version and the plugin loading so I couldn't have a look at it until now. Very interesting bug, the actual error is: An attempt was made to load a program with an incorrect format. (Exception from HRESULT: 0x8007000B)
It comes from the underlying wkhtmltopdf dependency executing native dll. When it runs the first time it extracts the file wkhtmltox0.dll being the native one and keeps it for the next executions. In your case, visual studio have been previously executed extracting it for 64 bits. If you run poweshell as user (64) it keeps working, however when you run it as admin by default it runs as 32 bits, the dll is then incompatible and crash. You can do the test by removing the wkhtmltox0.dll file in packages/Projbook.1.0.6/tools and it will likery work from your admin powershell but will crash switching back to visual studio. As a fix, I can try to detect that this hapenned, wipe the file and retry during the build, it would make it transparent.
Alright, so I just pushed an error message improvement (see right above). I tried to fix it silently but it will definitely lead to unpredictable behavior relating to file access hold by MSBuild. Also, because of https://github.com/defrancea/Projbook/issues/70, with 1.1 version you'll likely want to define the architecture you want to have the pdf generated on so it will be consistent across all builds. For your scenario, I advice you to simply run the script with the same architecture of the one you run your visual studio, it will make them compatible and everything should be alright. I'm closing the issue since everything has been figured out. Let me know if you need I release 1.0.7 now, but since it's just an error message I don't think it will be required. Thanks a lot for reporting that.
For example we have build scripts that call msbuild in a build folder (not the same folder as our SLN file)
msbuild.exe src\solution.sln /t:Clean;Build /p:Configuration=Release;VisualStudioVersion=12.0
And when running this command I receive the following error on build of the ProjBook project:
...template.pdf.html : error : Error during PDF generation: Exception has been thrown by the target of an invocation.
If i remove the Projbook.targets file from the Projbook csproj file then i can build without errors, but that obviously defeats the purpose. I have not dug into the source any more to try and figure out why it might be failing, but i feel like it might be path issue...