Can't build Nuget with Build.cmd

Topics: General
Sep 24, 2012 at 4:17 PM

I cloned the latest Nuget code and I get the following error when running build.cmd:

G:\NuGetCodePlex\nuget>build.cmdMicrosoft (R) Build Engine version 4.0.30319.17929[Microsoft .NET Framework, version 4.0.30319.17929]Copyright (C) Microsoft Corporation. All rights reserved.
  Core -> G:\NuGetCodePlex\nuget\src\Core\bin\Debug\NuGet.Core.dll  CommandLine -> G:\NuGetCodePlex\nuget\src\CommandLine\bin\Debug\NuGet.exe  Restoring NuGet packages  Could not load type 'NuGet.IPackageRepositoryFactory' from assembly 'NuGet, Version=2.1.0.0, Culture=neutral, PublicK  eyToken=null'.G:\NuGetCodePlex\nuget\Build\NuGet.Restore.targets(9,9): error MSB3073: The command "G:\NuGetCodePlex\nuget\Build\..\src\CommandLine\bin\debug\NuGet.exe install G:\NuGetCodePlex\nuget\test\Dialog.Test\packages.config -Source http://nuget.org/api/v2/ -out G:\NuGetCodePlex\nuget\Build\..\packages -verbosity quiet" exited with code 1. [G:\NuGetCodePlex\nuget\test\Dialog.Test\Dialog.Test.csproj]  Could not load type 'NuGet.IPackageRepositoryFactory' from assembly 'NuGet, Version=2.1.0.0, Culture=neutral, PublicK  eyToken=null'.G:\NuGetCodePlex\nuget\Build\NuGet.Restore.targets(9,9): error MSB3073: The command "G:\NuGetCodePlex\nuget\Build\..\src\CommandLine\bin\debug\NuGet.exe install G:\NuGetCodePlex\nuget\test\CommandLine.Test\packages.config -Source http://nuget.org/api/v2/ -out G:\NuGetCodePlex\nuget\Build\..\packages -verbosity quiet" exited with code 1. [G:\NuGetCodePlex\nuget\test\CommandLine.Test\CommandLine.Test.csproj]  Could not load type 'NuGet.IPackageRepositoryFactory' from assembly 'NuGet, Version=2.1.0.0, Culture=neutral, PublicK  eyToken=null'.G:\NuGetCodePlex\nuget\Build\NuGet.Restore.targets(9,9): error MSB3073: The command "G:\NuGetCodePlex\nuget\Build\..\src\CommandLine\bin\debug\NuGet.exe install G:\NuGetCodePlex\nuget\test\Core.Test\packages.config -Source http://nuget.org/api/v2/ -out G:\NuGetCodePlex\nuget\Build\..\packages -verbosity quiet" exited with code 1. [G:\NuGetCodePlex\nuget\test\Core.Test\Core.Test.csproj]  Could not load type 'NuGet.IPackageRepositoryFactory' from assembly 'NuGet, Version=2.1.0.0, Culture=neutral, PublicK  eyToken=null'.G:\NuGetCodePlex\nuget\Build\NuGet.Restore.targets(9,9): error MSB3073: The command "G:\NuGetCodePlex\nuget\Build\..\src\CommandLine\bin\debug\NuGet.exe install G:\NuGetCodePlex\nuget\test\PowerShellCmdlets.Test\packages.config -Source http://nuget.org/api/v2/ -out G:\NuGetCodePlex\nuget\Build\..\packages -verbosity quiet" exited with code 1. [G:\NuGetCodePlex\nuget\test\PowerShellCmdlets.Test\PowerShellCmdlets.Test.csproj]  Could not load type 'NuGet.IPackageRepositoryFactory' from assembly 'NuGet, Version=2.1.0.0, Culture=neutral, PublicK  eyToken=null'.G:\NuGetCodePlex\nuget\Build\NuGet.Restore.targets(9,9): error MSB3073: The command "G:\NuGetCodePlex\nuget\Build\..\src\CommandLine\bin\debug\NuGet.exe install G:\NuGetCodePlex\nuget\test\VisualStudio.Test\packages.config -Source http://nuget.org/api/v2/ -out G:\NuGetCodePlex\nuget\Build\..\packages -verbosity quiet" exited with code 1. [G:\NuGetCodePlex\nuget\test\VisualStudio.Test\VisualStudio.Test.csproj]  Could not load type 'NuGet.IPackageRepositoryFactory' from assembly 'NuGet, Version=2.1.0.0, Culture=neutral, PublicK  eyToken=null'.G:\NuGetCodePlex\nuget\Build\NuGet.Restore.targets(9,9): error MSB3073: The command "G:\NuGetCodePlex\nuget\Build\..\src\CommandLine\bin\debug\NuGet.exe install G:\NuGetCodePlex\nuget\test\PowerShellHost.Test\packages.config -Source http://nuget.org/api/v2/ -out G:\NuGetCodePlex\nuget\Build\..\packages -verbosity quiet" exited with code 1. [G:\NuGetCodePlex\nuget\test\PowerShellHost.Test\PowerShellHost.Test.csproj]  Could not load type 'NuGet.IPackageRepositoryFactory' from assembly 'NuGet, Version=2.1.0.0, Culture=neutral, PublicK  eyToken=null'.G:\NuGetCodePlex\nuget\Build\NuGet.Restore.targets(9,9): error MSB3073: The command "G:\NuGetCodePlex\nuget\Build\..\src\CommandLine\bin\debug\NuGet.exe install G:\NuGetCodePlex\nuget\test\Server.Test\packages.config -Source http://nuget.org/api/v2/ -out G:\NuGetCodePlex\nuget\Build\..\packages -verbosity quiet" exited with code 1. [G:\NuGetCodePlex\nuget\test\Server.Test\Server.Test.csproj]  Could not load type 'NuGet.IPackageRepositoryFactory' from assembly 'NuGet, Version=2.1.0.0, Culture=neutral, PublicK  eyToken=null'.G:\NuGetCodePlex\nuget\Build\NuGet.Restore.targets(9,9): error MSB3073: The command "G:\NuGetCodePlex\nuget\Build\..\src\CommandLine\bin\debug\NuGet.exe install G:\NuGetCodePlex\nuget\test\TeamFoundationServer.Test\packages.config -Source http://nuget.org/api/v2/ -out G:\NuGetCodePlex\nuget\Build\..\packages -verbosity quiet" exited with code 1. [G:\NuGetCodePlex\nuget\test\TeamFoundationServer.Test\TeamFoundationServer.Test.csproj]  Could not load type 'NuGet.IPackageRepositoryFactory' from assembly 'NuGet, Version=2.1.0.0, Culture=neutral, PublicK  eyToken=null'.G:\NuGetCodePlex\nuget\Build\NuGet.Restore.targets(9,9): error MSB3073: The command "G:\NuGetCodePlex\nuget\Build\..\src\CommandLine\bin\debug\NuGet.exe install G:\NuGetCodePlex\nuget\test\Test.Integration\packages.config -Source http://nuget.org/api/v2/ -out G:\NuGetCodePlex\nuget\Build\..\packages -verbosity quiet" exited with code 1. [G:\NuGetCodePlex\nuget\test\Test.Integration\Test.Integration.csproj]  Could not load type 'NuGet.IPackageRepositoryFactory' from assembly 'NuGet, Version=2.1.0.0, Culture=neutral, PublicK  eyToken=null'.G:\NuGetCodePlex\nuget\Build\NuGet.Restore.targets(9,9): error MSB3073: The command "G:\NuGetCodePlex\nuget\Build\..\src\CommandLine\bin\debug\NuGet.exe install G:\NuGetCodePlex\nuget\test\Test.Utility\packages.config -Source http://nuget.org/api/v2/ -out G:\NuGetCodePlex\nuget\Build\..\packages -verbosity quiet" exited with code 1. [G:\NuGetCodePlex\nuget\test\Test.Utility\Test.Utility.csproj]  Could not load type 'NuGet.IPackageRepositoryFactory' from assembly 'NuGet, Version=2.1.0.0, Culture=neutral, PublicK  eyToken=null'.G:\NuGetCodePlex\nuget\Build\NuGet.Restore.targets(9,9): error MSB3073: The command "G:\NuGetCodePlex\nuget\Build\..\src\CommandLine\bin\debug\NuGet.exe install G:\NuGetCodePlex\nuget\src\Server\packages.config -Source http://nuget.org/api/v2/ -out G:\NuGetCodePlex\nuget\Build\..\packages -verbosity quiet" exited with code 1. [G:\NuGetCodePlex\nuget\src\Server\Server.csproj]

 

A co-worker pulled down the code and it builds just fine with the command. I can open the solution and the command line will build. When I run the built command line against my solutions I get the following error:

 Unable to load one or more of the requested types. Retrieve the LoaderExceptions property for more information.

Again, I am unable to reproduce this on anyone else's machine.

I believe this is specific to my machine, like I don't have something installed or something is mis-configured. I am using Win 7 64 bit with VS2012. Any ideas?

Developer
Sep 24, 2012 at 5:24 PM

Are you using the ILMerged copy of the executable (It should be in bin\$(Configuration)\Merged)? If not, you'd need to ensure NuGet.Core.dll is sitting next to the executable.

Sep 24, 2012 at 6:01 PM

I am using the merged version. 

Just running the exe without parameters src\CommandLine\bin\Debug\Merged\NuGet.exe

I get

Unable to load one or more of the requested types. Retrieve the LoaderExceptions property for more information.

 

Also, running the same exe on another machine doesn't give me this error. Are there some system libraries I should ensure I have installed?

Sep 24, 2012 at 6:06 PM
Edited Sep 24, 2012 at 6:16 PM

I stepped into debug, it breaks on line 134 of Program.cs in the Initialize method, which is the last line in the snippet:

 

container.ComposeExportedValue(console);
container.ComposeExportedValue(settings);
container.ComposeExportedValue(new NuGet.Common.CommandLineRepositoryFactory());
container.ComposeExportedValue(packageSourceProvider);
container.ComposeExportedValue(credentialProvider);
container.ComposeExportedValue(fileSystem);
container.ComposeParts(this);

 

With the following exception:

{"Could not load type 'NuGet.IPackageRepositoryFactory' from assembly 'NuGet, Version=2.1.0.0, Culture=neutral, PublicKeyToken=null'.":"NuGet.IPackageRepositoryFactory"}

Sep 24, 2012 at 6:31 PM

I debugged a little more into the merged exe (I turned on pdb merging by removing the /ndebug flag from the ilmerge command). The code breaks on the same place as above, but I get the following exception:

"Unable to load one or more of the requested types. Retrieve the LoaderExceptions property for more information."

Here is the LoaderExceptions:

"Method 'GetValue' in type 'NuGet.Extras.BlankUserSettings' from assembly 'NuGet.Extras, Version=1.0.0.12, Culture=neutral, PublicKeyToken=null' does not have an implementation.":"NuGet.Extras.BlankUserSettings"

Stack Trace:

   at System.Reflection.RuntimeModule.GetTypes(RuntimeModule module)
   at System.Reflection.RuntimeModule.GetTypes()
   at System.Reflection.Assembly.GetTypes()
   at System.ComponentModel.Composition.Hosting.AssemblyCatalog.get_InnerCatalog()
   at System.ComponentModel.Composition.Hosting.AssemblyCatalog.GetExports(ImportDefinition definition)
   at System.ComponentModel.Composition.Hosting.AggregateCatalog.GetExports(ImportDefinition definition)
   at System.ComponentModel.Composition.Hosting.CatalogExportProvider.InternalGetExportsCore(ImportDefinition definition, AtomicComposition atomicComposition)
   at System.ComponentModel.Composition.Hosting.CatalogExportProvider.InnerCatalogExportProvider.GetExportsCore(ImportDefinition definition, AtomicComposition atomicComposition)
   at System.ComponentModel.Composition.Hosting.ExportProvider.TryGetExportsCore(ImportDefinition definition, AtomicComposition atomicComposition, IEnumerable`1& exports)
   at System.ComponentModel.Composition.Hosting.ExportProvider.TryGetExports(ImportDefinition definition, AtomicComposition atomicComposition, IEnumerable`1& exports)
   at System.ComponentModel.Composition.Hosting.CatalogExportProvider.GetExportsCore(ImportDefinition definition, AtomicComposition atomicComposition)
   at System.ComponentModel.Composition.Hosting.ExportProvider.TryGetExportsCore(ImportDefinition definition, AtomicComposition atomicComposition, IEnumerable`1& exports)
   at System.ComponentModel.Composition.Hosting.AggregateExportProvider.GetExportsCore(ImportDefinition definition, AtomicComposition atomicComposition)
   at System.ComponentModel.Composition.Hosting.ExportProvider.TryGetExportsCore(ImportDefinition definition, AtomicComposition atomicComposition, IEnumerable`1& exports)
   at System.ComponentModel.Composition.Hosting.ExportProvider.TryGetExports(ImportDefinition definition, AtomicComposition atomicComposition, IEnumerable`1& exports)
   at System.ComponentModel.Composition.Hosting.CompositionContainer.GetExportsCore(ImportDefinition definition, AtomicComposition atomicComposition)
   at System.ComponentModel.Composition.Hosting.ExportProvider.TryGetExportsCore(ImportDefinition definition, AtomicComposition atomicComposition, IEnumerable`1& exports)
   at System.ComponentModel.Composition.Hosting.ExportProvider.GetExports(ImportDefinition definition, AtomicComposition atomicComposition)
   at System.ComponentModel.Composition.Hosting.ImportEngine.TryGetExports(ExportProvider provider, ComposablePart part, ImportDefinition definition, AtomicComposition atomicComposition)
   at System.ComponentModel.Composition.Hosting.ImportEngine.TrySatisfyImportSubset(PartManager partManager, IEnumerable`1 imports, AtomicComposition atomicComposition)
   at System.ComponentModel.Composition.Hosting.ImportEngine.TryPreviewImportsStateMachine(PartManager partManager, ComposablePart part, AtomicComposition atomicComposition)
   at System.ComponentModel.Composition.Hosting.ImportEngine.PreviewImports(ComposablePart part, AtomicComposition atomicComposition)
   at System.ComponentModel.Composition.Hosting.ComposablePartExportProvider.Compose(CompositionBatch batch)
   at System.ComponentModel.Composition.Hosting.CompositionContainer.Compose(CompositionBatch batch)
   at System.ComponentModel.Composition.AttributedModelServices.ComposeParts(CompositionContainer container, Object[] attributedParts)
   at NuGet.Program.Initialize(IFileSystem fileSystem, IConsole console) in g:\NuGetCodePlex\nuget\src\CommandLine\Program.cs:line 134

Developer
Sep 24, 2012 at 6:54 PM

NuGet.Extras doesn't look like one of our assemblies. It's probably an extension getting loaded from %AppData%\NuGet\Extensions

Sep 24, 2012 at 7:51 PM

That was it. I installed it a long time ago and don't use, so I deleted it.

Thanks!