PowerShellToolsPro.Packager in 4.0.29. POSH tools is broken again

Issue #27 resolved
Former user created an issue

The "build" feature is back to crashing again, I uninstalled/reinstalled VS 2017 15.8.7 and then installed 4.0.29. POSH tools. In VS2017, using Help->About PowerShell Pro Tools, I re-entered my license key.

Regardless - PowerShellToolsPro.Packager appears to be broken again

My powershell scripts are failing to "build" within VS 2017. The scripts execute just fine outside of VS2017, but when I try and "build" them for the purpose of bundling and/or creating an EXE, the PowerShellToolsPro.Packager crashes

$psversiontable

Name                           Value                                                                                                                                                                                                     
----                           -----                                                                                                                                                                                                     
PSVersion                      5.1.14409.1018                                                                                                                                                                                            
PSEdition                      Desktop                                                                                                                                                                                                   
PSCompatibleVersions           {1.0, 2.0, 3.0, 4.0...}                                                                                                                                                                                   
BuildVersion                   10.0.14409.1018                                                                                                                                                                                           
CLRVersion                     4.0.30319.42000                                                                                                                                                                                           
WSManStackVersion              3.0                                                                                                                                                                                                       
PSRemotingProtocolVersion      2.3                                                                                                                                                                                                       
SerializationVersion           1.1.0.1 

Here is the VS2017 Output log from doing a rebuild of my project. See notes about PowerSHellProTools.target after the log

====================================

------ Rebuild All started: Project: PowerShellCommon, Configuration: Release Any CPU ------
 Checking license
 OutputPath is C:\Users\administrator\Documents\Visual Studio 2017\Projects\PowerShell\PowerShellCommon\bin\Release\
 Bundling DisplayMessage-ReturnAnswer.ps1
 Bundle result: C:\Users\administrator\Documents\Visual Studio 2017\Projects\PowerShell\PowerShellCommon\bin\Release\DisplayMessage-ReturnAnswer.ps1
------ Rebuild All started: Project: Create-XenSnapshotsUi, Configuration: Release Any CPU ------
 Checking license
 OutputPath is C:\Users\administrator\Documents\Visual Studio 2017\Projects\PowerShell\XenSnapShots\Create-XenSnapshotsUi\bin\Release\
 Bundling FormMain.ps1
C:\Program Files (x86)\Microsoft Visual Studio\2017\Professional\MSBuild\PowerShell Tools for Visual Studio\PowerShellProTools.targets(5,5): error MSB4018: The "PowerShellPackageTask" task failed unexpectedly.
System.ArgumentNullException: Value cannot be null.
Parameter name: value
   at System.String.Insert(Int32 startIndex, String value)
   at PowerShellToolsPro.Packager.Bundler.Bundle(String root)
   at PowerShellToolsPro.Packager.BundleStage.Execute(PackageProcess process, StageResult previousStage)
   at PowerShellToolsPro.Packager.PackageProcess.Execute()
   at PowerShellToolsPro.MsBuild.PowerShellPackageTask.Execute()
   at Microsoft.Build.BackEnd.TaskExecutionHost.Microsoft.Build.BackEnd.ITaskExecutionHost.Execute()
   at Microsoft.Build.BackEnd.TaskBuilder.<ExecuteInstantiatedTask>d__26.MoveNext()
Done building project "Create-XenSnapshotsUi.pssproj" -- FAILED.

Build FAILED.

====================================

VS2017 points to the PowerShellProTools.target file and says that the error is on line 5, the "<PowerShellPackageTask" line

<Project xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
  <UsingTask AssemblyFile="PowerShellToolsPro.MsBuild.dll" TaskName="PowerShellToolsPro.MsBuild.PowerShellPackageTask" />

  <Target Name="PowerShellPackage" AfterTargets="Build">
    <PowerShellPackageTask PackageEntryPoint="$(PackageEntryPoint)"
                           PackageAsExecutable="$(PackageAsExecutable)"
                           DotNetVersion="$(DotNetVersion)"
                           Bundle="$(Bundle)"
                           OutputDirectory="$(OutputPath)"
                           Obfuscate="$(Obfuscate)"
                           HideConsoleWindow="$(HideConsoleWindow)"
                           FileVersion="$(FileVersion)"
                           FileDescription="$(FileDescription)"
                           ProductName="$(ProductName)"
                           ProductVersion="$(ProductVersion)"
                           Copyright="$(Copyright)"
                           RequireElevation="$(RequireElevation)"
                           ApplicationIconPath="$(ApplicationIconPath)"
                           PackageModules="$(PackageModules)"
                           PackageType="$(PackageType)"
                           ServiceName="$(ServiceName)"
                           ServiceDisplayName="$(ServiceDisplayName)"/>
  </Target>
</Project>

Comments (2)

  1. Bill Charlton

    I'm the author of the issue - please close this issue. Adam traced the build failure to a malformed path in one of my join-path statements. He said he'd look at providing a more meaningful error message. In any case, after fixing the path in my join-path statement, my stuff builds fine.

  2. Log in to comment