Skip to content
This repository has been archived by the owner on Dec 20, 2018. It is now read-only.

Unable to bundle ps1 scripts #16

Open
hou8182 opened this issue May 13, 2018 · 8 comments
Open

Unable to bundle ps1 scripts #16

hou8182 opened this issue May 13, 2018 · 8 comments
Labels
bug Something isn't working

Comments

@hou8182
Copy link

hou8182 commented May 13, 2018

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 adamdriscoll added the bug Something isn't working label May 20, 2018
@adamdriscoll
Copy link
Member

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

@hou8182
Copy link
Author

hou8182 commented May 20, 2018

I am running PoshTools 3.0.552 and PoshTool Pro 1.4.0

@adamdriscoll
Copy link
Member

Try updating to PoshTools 3.1.620.

@hou8182
Copy link
Author

hou8182 commented May 20, 2018

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
Copy link
Member

@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
Copy link

n3-ss commented May 21, 2018

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

@hou8182
Copy link
Author

hou8182 commented May 21, 2018

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
Copy link
Member

@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

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

3 participants