Package script as Exe not working - Requires SDK then term Merge-Script not recognized

Visual Studio Code
Version: 1.66.2 (user setup)
Commit: dfd34e8260c270da74b5c2d86d61aee4b6d56977
Date: 2022-04-11T07:46:01.075Z
Electron: 17.2.0
Chromium: 98.0.4758.109
Node.js: 16.13.0
OS: Windows_NT x64 10.0.19044

I am trying to create an executable from a simple PowerShell script. When I right-click the Test.ps1 and choose the option to “Package script as Exe”, it creates the package.psd1 file with DotNetVersion 4.6.2. It then says that I need to install Dev SDK. I did that and now if I try again it says:

“Merge-Script : The term ‘Merge-Script’ is not recognized as the name of a cmdlet,
function, script file, or operable program. Check the spelling of the name, or if a path
was included, verify that the path is correct and try again.”

When I uninstall SDK, I get the same original error saying missing SDK.

I have .NET 4.8 installed. As well as these…

3.1.201 [C:\Program Files\dotnet\sdk]

C:\WINDOWS\system32>dotnet --list-runtimes
Microsoft.AspNetCore.All 2.1.17 [C:\Program Files\dotnet\shared\Microsoft.AspNetCore.All]
Microsoft.AspNetCore.App 2.1.17 [C:\Program Files\dotnet\shared\Microsoft.AspNetCore.App]
Microsoft.AspNetCore.App 3.1.3 [C:\Program Files\dotnet\shared\Microsoft.AspNetCore.App]
Microsoft.AspNetCore.App 3.1.24 [C:\Program Files\dotnet\shared\Microsoft.AspNetCore.App]
Microsoft.NETCore.App 2.1.17 [C:\Program Files\dotnet\shared\Microsoft.NETCore.App]
Microsoft.NETCore.App 3.1.3 [C:\Program Files\dotnet\shared\Microsoft.NETCore.App]
Microsoft.NETCore.App 3.1.24 [C:\Program Files\dotnet\shared\Microsoft.NETCore.App]
Microsoft.WindowsDesktop.App 3.1.3 [C:\Program Files\dotnet\shared\Microsoft.WindowsDesktop.App]
Microsoft.WindowsDesktop.App 3.1.24 [C:\Program Files\dotnet\shared\Microsoft.WindowsDesktop.App]

Any suggestions on how to get the script converted to an exe?


Hi @KarlSack , I’m trying to recreate this on my side. Can you share a screenshot of selecting Package script as Exe from the right-click menu? I don’t see that on my end. I only have the option in the upper-right of VS Code (pictured below).


I get the same results when I choose right-click on Test.ps1 or click on the upper right icon.

I got it to work now. I downloaded Dev SDK 4.6.2 and lowered the package to use 4.6.2 instead of 4.8.0. I was able to create the .exe.

However, when I ran it, my Anti-Virus software (McAfee) reported it and sent it to be quarantined.

I looked online and didn’t see a way to stop that. Any suggestions?

I’m glad you were able to find a way forward. For the Antivirus, usually the best approach is to create an exception within the application for that particular folder.

You may need to look carefully at the detection event to see the precise folder where the file was convicted and then add that folder to the Antivirus exception list (e.g. c:\temp).

The reason that the file is convicted is most likely not because it is a threat because it is unknown. It has no provenance or reputation since it was just created a few moments ago. If you’re not able to make progress with this, feel free to share screenshots from the antivirus program.

Thanks @DataTraveler I will give that a go! Cheers.