Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

PackageWeb fails to unzip when run under a Windows Service account #48

Open
tbehunin opened this issue Feb 12, 2013 · 4 comments
Open
Milestone

Comments

@tbehunin
Copy link

For some reason when Publish-Interactive.ps1 is executed as a Windows Service (e.g. automated builds, continuous integration environments, etc.), it silently fails to extract the zip - no error message is indicated anywhere as to the reason why it doesn't unzip. Everything appears to function fine, with the exception to the following method call:

$destinationFolder.CopyHere($zipPackage.Items())
@ghost ghost assigned sayedihashimi Feb 12, 2013
@sayedihashimi
Copy link
Owner

Thanks for the bug report, will look into this.

@kpartusch
Copy link

@sayedihashimi I was experiencing this issue and found an article explaining how to use the compression library in .NET 4.5. I have done some preliminary tests using this method and it seems to work when running the build in TeamCity with a service account. I wanted to know what I needed to include in my pull request to get this change included and released.

@sayedihashimi
Copy link
Owner

@kpartusch thanks for the request. In general as long as your code works I'll take it in any shape.

If you're asking what I think would be ideal, then continue reading. When I created PackageWeb I was very new to PowerShell. Because of that the code isn't the prettiest and likely does some funny things.

Since then I've improved and I'd like to ensure that new code is good quality. For functions I'd like them to have

  • [cmdletbinding()] attribute
  • Some comments in the form of PS help (doesn't have to be much)
  • Should support pipeline when it makes sense
  • Should use Write-Verbose for diagnostic messages

For an example of how I write PowerShell these days see one of my other repos for ex: https://github.com/ligershark/psbuild/blob/master/src/psbuild.psm1.

@sayedihashimi sayedihashimi removed their assignment Dec 31, 2014
@jmbezeau
Copy link

jmbezeau commented Sep 11, 2017

I have made two adjustments in order to have Publish-Interactive.ps1 work with my "Release Management" definition. I call my install PowerShell with Remote PowerShell Task.

So in my main script, I added a simple Write-Host fonction, thus overriding the build-in function.
function Write-Host($string) {
$string
}

In the Publish-Interactive.ps1, I replaced the Extract-Zip function with the following code:
function Extract-Zip {
param(
[string]$zipfilename = $(throw "zipfilename is a required parameter for Extract-Zip"),
[string]$destination = $(throw "destination is a required parameter for Extract-Zip"))

if(!(Test-Path $zipFilename)) { throw [system.IO.FileNotFoundException] ("Zipfile not found at [{0}]" -f $zipFilename)   }
if(!(Test-Path $destination)) { throw [system.IO.DirectoryNotFoundException] ("destination not found at [{0}]" -f $destination) }

# required in case there are any .. or . characters in the path
$zipFilename = (Resolve-Path $zipFilename)
$destination = (Resolve-Path $destination)

if(test-path($zipfilename))
{	
	Add-Type -Assembly 'System.IO.Compression.FileSystem'
	[System.IO.Compression.ZipFile]::ExtractToDirectory($zipfilename, $destination)
}
else{
	Write-Error ("Zipfile not found [{0}]" -f $zipFilename)
}

}

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

4 participants