Occasional "Access Denied" exception with Remove-Package

Oct 9, 2010 at 6:11 AM

Every now and then I get an "Access Denied" exception when calling Remove-Package (see exception message below). A bit odd, because if I Add-Package the same package and call Remove-Package again it works, and seems to work every subsequent time.

PM> Remove-Package "CSLA Light"
Successfully removed 'CSLA Light 3.8.4' from SilverlightApplication1
_WriteError : Access to the path 'D:\Development\Other\SilverlightApplication1\packages\CSLA Light.3.8.4\Lib\SL4.0\' is denied.
At C:\Program Files (x86)\Microsoft Visual Studio 10.0\Common7\IDE\Extensions\CodePlex Foundation\NuPack Tools\0.1\Scripts\nupack.ps1:159 char:24
+             _WriteError <<<<  $_.Exception
    + CategoryInfo          : NotSpecified: (:) [Write-Error], WriteErrorException
    + FullyQualifiedErrorId : Microsoft.PowerShell.Commands.WriteErrorException,_WriteError

Not a train smash since there's a workaround, but I though you should know.

Oct 9, 2010 at 6:18 AM

I've seen intermittent issues like this every now and then. Error recovery is something we'll definitely improve. Thanks alot for reporting this. Could you file a work item with possible repro steps?

Oct 9, 2010 at 6:32 AM

Yes, this one is ugly.  Some kind of timing issue at the file system level.  I occasionally hit the same thing trying to delete a folder from the Windows shell, where it fails with access denied, and succeeds on the next try.  Maybe we need a little retry loop that sleeps for a short while (100 ms) and tries again up to 500 am.

Oct 9, 2010 at 6:36 AM

Sure no problem.
See issue #213: http://nupack.codeplex.com/workitem/213 
(I've also attached a test package of mine that this is happening with)

Ps: I've also noticed that the Add-Package doesn't ALWAYS show the message about licensing and sometimes just states that the package was added successfully.

Ps2: The .nupkg files are Zip packages but aren't compressed very well, if at all. Manually compressing the same content results in a much smaller ZIP file.

Oct 9, 2010 at 7:57 AM

It only shows license information for packages that state that they require it.

Thanks for the tip I just set the compression option to maximum and it's alot better.

Oct 9, 2010 at 8:24 AM


Re: the License information - Yes, that's how I understood it. I have a package that requires it, but it doesn't always state it. Sometimes it just adds it? Or does it keep state about the fact that I've previously accepted it?

Oct 9, 2010 at 3:19 PM

Yes, within the same solution, we only show the license information the first time you add it to any project.

Oct 9, 2010 at 3:43 PM

And it only shows the license once per package per solution. So if you installed it to Project A in your solution. And then add it to Project B we won’t show it again for two reasons:

1. We know you already accepted it because it exists in Project A.

2. The license acceptance is part of the download. When you add it to project B, we just grab the package from the packages folder in your solution. We don’t need to re-download it.

Oct 9, 2010 at 11:20 PM

Ah that explains it... and it makes sense too. I also now better understand what you meant about aggressive caching in another post.

Thanks for the quick turnaround!