The issue was having the packages folder in the same directory as the csproj file.
The original setup was this:
C:\DEV\ATTACHMENTUNITTESTS\
+---.nuget\
+---AttachmentUnitTests.sln
+---AttachmentUnitTests.csproj
+---packages\
\---WebDriver.IEDriverServer.win32.2.42.0\
AttachmentUnitTests.csproj has this incorrect ItemGroup entry
<ItemGroup>
<Content Include="packages\WebDriver.IEDriverServer.win32.2.42.0\content\IEDriverServer.exe" />
</ItemGroup>
Changing the structure so that the CSPROJ was in it's own subdirectory made the issue go away.
C:\DEV\ATTACHMENTUNITTESTS\
+---.nuget\
+---AttachmentUnitTests.sln
+---AttachmentUnitTests\
| +---Packages.config
| \---AttachmentUnitTests.csproj
+---packages\
\---WebDriver.IEDriverServer.win32.2.42.0\
AttachmentUnitTests.csproj has this correct ItemGroup entry
<ItemGroup>
<Content Include="..\packages\WebDriver.IEDriverServer.win32.2.42.0\content\IEDriverServer.exe">
<Link>IEDriverServer.exe</Link>
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
</Content>
</ItemGroup>
The fix for this issue is to move the CSPROJ to a sufolder that does not include the Packages folder.
I was able to get the original install working fine using a modified install.ps1, which illustrates that the issue because
param($installPath, $toolsPath, $package, $project)
$file = Join-Path (Join-Path $toolsPath '..\content') 'IEDriverServer.exe' | Get-ChildItem
# IEDriverServer.exe is copied to the project root because it's in the content folder of the nupkg
# this line will always work because the file exists as a copy in the root of the project
$project.ProjectItems.Item($file.Name).Delete()
# now we want to re-add it as a linked item in the Packages folder
$pi = $project.ProjectItems.AddFromFile($file.FullName);
# reference the original item returned by AddFromFile, no need to go looking again
#$pi = $project.ProjectItems.Item($file.Name);
$pi.Properties.Item("BuildAction").Value = [int]2;
#2 = prjBuildActionContent - The file is included in the Content project output group
...and this modified uninstall.ps1
param($installPath, $toolsPath, $package, $project)
# original code didn't work when packages\ is in same folder as csproj
#$file = Join-Path (Join-Path $toolsPath '..\content') 'IEDriverServer.exe' | Get-ChildItem
#$project.ProjectItems.Item($file.Name).Delete()
# don't show nasty red warnings.
$ErrorActionPreference = "SilentlyContinue"
# create a variable with null value
$pi = $null
# does
$pi = $project.ProjectItems.Item($file.Name)
if $pi -eq $null then $pi = $project.ProjectItems.Item("packages").ProjectItems.Item($package).ProjectItems.Item("content").ProjectItems.Item("IEDriverServer.exe")
if $pi -ne $null then $pi.Delete()
$file.Namereturn? - Lasse V. Karlsen