InvalidProjectFileException while installing packages

Topics: General
Jul 26, 2013 at 12:30 PM
We're currently trying to migrate to NuGet. However, we've hit a roadblock: Randomly, while installing packages, an error would occur. With the advent of our "most dependent" package yet, this error is occurring every time.
Here's an excerpt from the package manager console.
PM> Install-Package MyPackage -Source http://buildserver:8000/release/nuget
Attempting to resolve dependency 'Package1 (= 2.0.1.0)'.
Attempting to resolve dependency 'Package2 (= 2.0.0.0)'.
Attempting to resolve dependency 'Package3 (= 9.1.5.0)'.
Attempting to resolve dependency 'Package4 (= 2.0.0.0)'.
Attempting to resolve dependency 'Package5 (= 1.2.10.0)'.
Attempting to resolve dependency 'Package6 (= 2.5.10.0)'.
Attempting to resolve dependency 'Package7 (= 2.0.1.0)'.
Attempting to resolve dependency 'Package8 (= 2.0.1.0)'.
Attempting to resolve dependency 'Package9 (= 2.0.1.0)'.
Attempting to resolve dependency 'Package10 (= 2.0.0.0)'.
Attempting to resolve dependency 'Package11 (= 2.0.3.0)'.
Attempting to resolve dependency 'Package12 (= 2.0.2.0)'.
Attempting to resolve dependency 'Package13 (= 2.0.0.0)'.
Attempting to resolve dependency 'Package14 (= 2.4.0.1)'.
Attempting to resolve dependency 'Package15 (= 2.0.1.0)'.
Attempting to resolve dependency 'Package16 (= 2.0.0.0)'.
Attempting to resolve dependency 'Package17 (= 2.0.5.0)'.
Attempting to resolve dependency 'Package18 (= 2.5.2.0)'.
Attempting to resolve dependency 'Package19 (= 0.86.0.518)'.
Attempting to resolve dependency 'Package20 (= 2.7.3.1000)'.
Attempting to resolve dependency 'Package21 (= 2.0.1.0)'.
Attempting to resolve dependency 'Package22 (= 2.0.2.0)'.
Attempting to resolve dependency 'Package23 (= 2.0.0.0)'.
Attempting to resolve dependency 'Package24 (= 12.2.4.0)'.
Attempting to resolve dependency 'Package25 (= 2.0.1.0)'.
Attempting to resolve dependency 'Package26 (= 2.0.0.0)'.
Attempting to resolve dependency 'Package27 (= 2.0.0.0)'.
Attempting to resolve dependency 'Package28 (= 2.0.0.0)'.
Attempting to resolve dependency 'Package29 (= 2.0.0.0)'.
Attempting to resolve dependency 'Package30 (= 2.0.0.0)'.
Attempting to resolve dependency 'Package31 (= 2.0.7.0)'.
Attempting to resolve dependency 'Package32 (= 1.1.0.0)'.
Attempting to resolve dependency 'Package33 (= 2.0.0.0)'.
Attempting to resolve dependency 'Package34 (= 2.0.0.0)'.
Attempting to resolve dependency 'Package35 (= 2.0.0.0)'.
Installing 'Package3 9.1.5.0'.
Successfully installed 'Package3 9.1.5.0'.
Installing 'Package5 1.2.10.2'.
Successfully installed 'Package5 1.2.10.2'.
Installing 'Package6 2.5.10.2'.
Successfully installed 'Package6 2.5.10.2'.
Installing 'Package4 2.0.6.0'.
Successfully installed 'Package4 2.0.6.0'.
Installing 'Package7 2.0.1.0'.
Successfully installed 'Package7 2.0.1.0'.
Installing 'Package2 2.0.0.0'.
Successfully installed 'Package2 2.0.0.0'.
Installing 'Package1 2.0.1.0'.
Successfully installed 'Package1 2.0.1.0'.
Installing 'Package11 2.0.3.0'.
Successfully installed 'Package11 2.0.3.0'.
Installing 'Package12 2.0.6.0'.
Successfully installed 'Package12 2.0.6.0'.
Installing 'Package10 2.0.7.0'.
Successfully installed 'Package10 2.0.7.0'.
Installing 'Package14 2.4.0.2'.
Successfully installed 'Package14 2.4.0.2'.
Installing 'Package13 2.0.1.0'.
Successfully installed 'Package13 2.0.1.0'.
Installing 'Package9 2.0.1.0'.
Successfully installed 'Package9 2.0.1.0'.
Installing 'Package16 2.0.0.0'.
Successfully installed 'Package16 2.0.0.0'.
Installing 'Package18 2.5.2.1'.
Successfully installed 'Package18 2.5.2.1'.
Installing 'Package19 0.86.0.5182'.
Successfully installed 'Package19 0.86.0.5182'.
Installing 'Package20 2.7.3.10002'.
Successfully installed 'Package20 2.7.3.10002'.
Installing 'Package17 2.0.6.0'.
Successfully installed 'Package17 2.0.6.0'.
Installing 'Package21 2.0.1.0'.
Successfully installed 'Package21 2.0.1.0'.
Installing 'Package15 2.0.1.0'.
Successfully installed 'Package15 2.0.1.0'.
Installing 'Package22 2.0.2.0'.
Successfully installed 'Package22 2.0.2.0'.
Installing 'Package8 2.0.2.0'.
Successfully installed 'Package8 2.0.2.0'.
Installing 'Package24 12.2.4.0'.
Successfully installed 'Package24 12.2.4.0'.
Installing 'Package25 2.0.1.0'.
Successfully installed 'Package25 2.0.1.0'.
Installing 'Package27 2.0.0.0'.
Successfully installed 'Package27 2.0.0.0'.
Installing 'Package26 2.0.0.0'.
Successfully installed 'Package26 2.0.0.0'.
Installing 'Package29 2.0.0.0'.
Successfully installed 'Package29 2.0.0.0'.
Installing 'Package30 2.0.0.0'.
Successfully installed 'Package30 2.0.0.0'.
Installing 'Package28 2.0.0.0'.
Successfully installed 'Package28 2.0.0.0'.
Installing 'Package32 1.1.0.0'.
Successfully installed 'Package32 1.1.0.0'.
Installing 'Package31 2.0.7.0'.
Successfully installed 'Package31 2.0.7.0'.
Installing 'Package33 2.0.2.0'.
Successfully installed 'Package33 2.0.2.0'.
Installing 'Package34 2.0.0.0'.
Successfully installed 'Package34 2.0.0.0'.
Installing 'Package35 2.0.0.0'.
Successfully installed 'Package35 2.0.0.0'.
Installing 'Package23 2.0.0.0'.
Successfully installed 'Package23 2.0.0.0'.
Installing 'MyPackage 2.0.0.0'.
Successfully installed 'MyPackage 2.0.0.0'.
Adding 'Package3 9.1.5.0' to BogusLibrary.
Successfully added 'Package3 9.1.5.0' to BogusLibrary.
Adding 'Package5 1.2.10.2' to BogusLibrary.
Successfully added 'Package5 1.2.10.2' to BogusLibrary.
Adding 'Package6 2.5.10.2' to BogusLibrary.
Successfully added 'Package6 2.5.10.2' to BogusLibrary.
Adding 'Package4 2.0.6.0' to BogusLibrary.
Uninstalling 'Package4 2.0.6.0'.
Successfully uninstalled 'Package4 2.0.6.0'.
Uninstalling 'Package6 2.5.10.2'.
Successfully uninstalled 'Package6 2.5.10.2'.
Uninstalling 'Package5 1.2.10.2'.
Successfully uninstalled 'Package5 1.2.10.2'.
Uninstalling 'Package3 9.1.5.0'.
Successfully uninstalled 'Package3 9.1.5.0'.
Install failed. Rolling back...
Install-Package : The result "" of evaluating the value "$(BuildTaskAssembly)" of the "AssemblyName" attribute in element <UsingTask> is not valid.  c:\Windows\Microsoft.NET\Framework\v4.0.30319\Microsoft.WinFX.targets
At line:1 char:16
+ Install-Package <<<<  MyPackage -Source http://buildserver:8000/release/nuget
    + CategoryInfo          : NotSpecified: (:) [Install-Package], InvalidProjectFileException
    + FullyQualifiedErrorId : NuGetCmdletUnhandledException,NuGet.PowerShell.Commands.InstallPackageCommand
 
PM> 
While the error itself occurs every time, the exact position in the installation process seems to be time-related. For the same project (in this case, an empty class library), it usually occurs at the same package, unless debugging Visual Studio itself.
I've already taken a look at the source code but couldn't find an obvious error.
The message about the eval result being empty is strange as well, considering there's a directive to ensure (I believe, at least) the variable isn't empty.

Software: Visual Studio 2012 with all the latest and greatest updates, NuGet 2.6.40627.9000.
If you need more info, please don't hesitate to ask! :)
Dec 17, 2013 at 1:15 PM
We have the same kind of problem. We use Visual Studio 2013 and sometimes during the update process we get the following error:

Update-Package : The result "" of evaluating the value "$(BuildTaskAssembly)" of the "AssemblyName" attribute in element <UsingTask> is not valid. C:\Windows\
Microsoft.NET\Framework\v4.0.30319\Microsoft.WinFx.targets
At line:1 char:15
  • update-package <<<<
    • CategoryInfo : NotSpecified: (:) [Update-Package], Exception
    • FullyQualifiedErrorId : NuGetCmdletUnhandledException,NuGet.PowerShell.Commands.UpdatePackageCommand
Jun 26, 2014 at 8:17 AM
Edited Jun 26, 2014 at 8:55 AM
We get that exact same error too, with NuGet 2.8.50313.31.

Could be the some later target overwrites $(BuildTaskAssembly), since path resolution happens at a later path than property resolution, see repro below.

And indeed, $(BuildTaskAssembly) is an overly-generic name - other target packs use something like $(AppxMSBuildTaskAssembly), $(WixTasksPath), etc.
<Project ToolsVersion="4.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
  <PropertyGroup>
    <BuildTaskAssembly>C:\temp\MyBuildTasks.dll</BuildTaskAssembly>
  </PropertyGroup>

  <UsingTask TaskName="SetFileLastWriteTimeUtc" AssemblyFile="$(BuildTaskAssembly)"/>

  <PropertyGroup Condition="'$(OverwritePath)' == 'true'">
    <BuildTaskAssembly />
  </PropertyGroup>

  <Target Name="Build" >
    <SetFileLastWriteTimeUtc FileName="c:\temp\b" TimeToSet="1980-05-19" />
  </Target>
</Project>
C:\temp\targettest > msbuild /nologo a.targets
Build started 2014-06-26 11:47:49.
Build succeeded.

C:\temp\targettest > msbuild /nologo a.targets /p:OverwritePath=true
Build started 2014-06-26 11:47:44.
Project "C:\temp\targettest\a.targets" on node 1 (default targets).
C:\temp\targettest\a.targets(6,49): error MSB4022: The result "" of evaluating the value "$(BuildTaskAssembly)" of the "AssemblyFile" attribute in element <UsingTask> is not valid.
Done Building Project "C:\temp\targettest\a.targets" (default targets) -- FAILED.