ironmansoftware / poshprotools

Issue tracker and examples for PowerShell Pro Tools. Not maintained! Click here ->
https://poshtools.com/issues
MIT License
25 stars 1 forks source link

Unable to bundle ps1 scripts #16

Open hou8182 opened 6 years ago

hou8182 commented 6 years ago

I am unable to find a way to bundle my ps1 scripts after creating my wpf application. I am running Win10, VS2017, and have installed .NET Core SDK 1.1.7 and .NET Framework 4.6.2 Developer Pack. I tried right clicking on my WPF Powershell Project and going to Properties, but I still did not see the option to bundle there as in this documentation: https://poshtools.com/docs/posh-pro-tools/bundling-packaging-msbuild/

Instead, these are the options I see:

capture

Side note - If I right click on my xaml window, I get a menu option to package as an executable, and this works when I run it, but it also pops up a blank powershell window in the background, is there a way to create the exe without that additional window in the background and also to create an custom icon for it?

adamdriscoll commented 6 years ago

What version of PoshTools and PoshTools pro are you running? I think you'll need to upgrade PoshTools based on the screenshot.

hou8182 commented 6 years ago

I am running PoshTools 3.0.552 and PoshTool Pro 1.4.0

adamdriscoll commented 6 years ago

Try updating to PoshTools 3.1.620.

hou8182 commented 6 years ago

Thanks! Doing the upgrade worked. Now I see the option to bundle the scripts and have checked it. What do I do next or where do I go to see my bundled ps1 file? Is it just the wpfWindow1.xaml.ps1?

I ran wpfWindow1.xaml.ps1 from the ise and it worked fine, but if I try launching the same script with a regular powershell window I get a bunch of red errors like:

Unable to find type [Windows.Markup.XamlReader] You cannot call a method on a null-valued expression.

adamdriscoll commented 6 years ago

@hou8182 That seems like a bug. I'm surprised this is the first I've heard of it. Can you try adding this to the beginning of your script?

[System.Reflection.Assembly]::LoadWithPartialName("PresentationFramework")
n3-ss commented 6 years ago

@adamdriscoll I was running into this same issue and that fixed the problem for me. Thanks.

hou8182 commented 6 years ago

Thanks! Adding [System.Reflection.Assembly]::LoadWithPartialName("PresentationFramework") to the top of the script worked. Now I'm curious how to get it to run without the separate powershell console window in the background.

This may be another bug: When adding a background image to a winform, it shows in my design window and when running the program from VS, but only when selecting a local resource file. If I choose to import a project resource file, the background image of my window in VS remains blank. When I package the form as an exe, I get this message:

image

image

*Notice that the console window still shows in the background, even though I selected the option to hide the console window.

Also, when running the build from VS, I always get the popup saying "This project is out of date. PowerShellProject4 Debug Any CPU". Is there a reason for this?

adamdriscoll commented 6 years ago

@hou8182 Could you please open a separate issue for the background? I will have to look into that.

As for hiding the console window, can you upload your PSSProj file? Seems like that setting isn't being saved or something.

And for the project is out of date issue, that's a problem with PoshTools: https://github.com/adamdriscoll/poshtools/issues/536