Build/Test Issues

NCrunch cannot compile projects with spaces in its name

Started by Ralf Koban on 5,501 views

Hi Remco,

(I've submitted a bug report on it but I got a message stating that this failed, so I post it here as well.)

I created a helper assembly that contains some spaces in its name ("MiKoSolutions.Aspects TestHelpers").

Now, when NCrunch 2.9.0.3 tries to compile, it does not succeed.
As soon as I change the name and remove the whitespace (eg. replace by a dot), NCrunch can compile the project. If I change it back, NCrunch fails on compilation again.




Log from NCrunch test window:


NCrunch: This project was built on server '(local)'
NCrunch: The tests in this project were discovered on server '(local)'

An error occurred while analysing this project after it was built: System.IO.FileNotFoundException: Die Datei oder Assembly "MiKoSolutions.Aspects TestHelpers, Version=1.0.0.0, Culture=neutral, PublicKeyToken=43261373ca9477f0" oder eine Abhängigkeit davon wurde nicht gefunden. Das System kann die angegebene Datei nicht finden.
Dateiname: 'MiKoSolutions.Aspects TestHelpers, Version=1.0.0.0, Culture=neutral, PublicKeyToken=43261373ca9477f0'
bei System.ModuleHandle.ResolveType(RuntimeModule module, Int32 typeToken, IntPtr* typeInstArgs, Int32 typeInstCount, IntPtr* methodInstArgs, Int32 methodInstCount, ObjectHandleOnStack type)
bei System.ModuleHandle.ResolveTypeHandleInternal(RuntimeModule module, Int32 typeToken, RuntimeTypeHandle[] typeInstantiationContext, RuntimeTypeHandle[] methodInstantiationContext)
bei System.ModuleHandle.ResolveTypeHandle(Int32 typeToken, RuntimeTypeHandle[] typeInstantiationContext, RuntimeTypeHandle[] methodInstantiationContext)
bei System.Reflection.RuntimeModule.ResolveType(Int32 metadataToken, Type[] genericTypeArguments, Type[] genericMethodArguments)
bei System.Reflection.CustomAttribute.FilterCustomAttributeRecord(CustomAttributeRecord caRecord, MetadataImport scope, Assembly& lastAptcaOkAssembly, RuntimeModule decoratedModule, MetadataToken decoratedToken, RuntimeType attributeFilterType, Boolean mustBeInheritable, Object[] attributes, IList derivedAttributes, RuntimeType& attributeType, IRuntimeMethodInfo& ctor, Boolean& ctorHasParameters, Boolean& isVarArg)
bei System.Reflection.CustomAttribute.GetCustomAttributes(RuntimeModule decoratedModule, Int32 decoratedMetadataToken, Int32 pcaCount, RuntimeType attributeFilterType, Boolean mustBeInheritable, IList derivedAttributes, Boolean isDecoratedTargetSecurityTransparent)
bei System.Reflection.CustomAttribute.GetCustomAttributes(RuntimeType type, RuntimeType caType, Boolean inherit)
bei NUnit.Core.CoreExtensions.InstallAdhocExtensions(Assembly assembly)
bei NUnit.Core.Builders.TestAssemblyBuilder.Load(String path)
bei NUnit.Core.Builders.TestAssemblyBuilder.Build(String assemblyName, Boolean autoSuites)
bei NUnit.Core.Builders.TestAssemblyBuilder.Build(String assemblyName, String testName, Boolean autoSuites)
bei NUnit.Core.TestSuiteBuilder.Build(TestPackage package)
bei nCrunch.Module.NUnit.Integration.NUnitDynamicTestFinder.FindFrameworkTestsUsingRuntimeInvoke(TestPackage package, ILogger logger, List`1 tests, Factory testNameFactory)
bei nCrunch.Module.NUnit.Integration.NUnitTestFramework.FindFrameworkTestsInAssembly(ReflectedAssembly assembly, FilePath assemblyFilePath, IList`1 referencedAssemblyFilePaths, ComponentUniqueName testComponentUniqueName)
bei nCrunch.TestExecution.TestFinder.FindTestsForFrameworks(ReflectedAssembly assembly, FilePath assemblyFilePath, IList`1 referencedAssemblyFilePaths, TestFrameworkDescription[] frameworks, ComponentUniqueName testComponentUniqueName)
bei nCrunch.TestExecution.RemoteTaskRunner.AnalyseAssembly(TestFrameworkDescription[] applicableFrameworks, ComponentUniqueName testComponentUniqueName)

WRN: Protokollierung der Assemblybindung ist AUS.
Sie können die Protokollierung der Assemblybindungsfehler aktivieren, indem Sie den Registrierungswert [HKLM\Software\Microsoft\Fusion!EnableLog] (DWORD) auf 1 festlegen.
Hinweis: Die Protokollierung der Assemblybindungsfehler führt zu einer gewissen Leistungseinbuße.
Sie können diese Funktion deaktivieren, indem Sie den Registrierungswert [HKLM\Software\Microsoft\Fusion!EnableLog] entfernen.
Hi, thanks for sharing this. I saw your bug report come through. I'll take a look at it and see if I can get it sorted.

Cheers,

Remco
Hi Remco,
I think I am facing the same issue as Ralf but Ralf's renaming solution didn't work for me. My VS solution has 6 projects in it most of which have spaces in there names and in the names of the files they contain but NCrunch is only complaining about one of the projects. I did what Ralf suggested and renamed all the projects substituting periods for spaces, still no go so I renamed the files in the projects removing the spaces, still the same issue. I cleaned and rebuilt the project then I selected the 'Reload and rebuild selected component' from the NCrunch Tests window context menu. I then run the configuration wizard from the NCrunch menu, still the same issue. I then went through and removed all the .NCrunchsolution and .NCrunchproject files and the _NCrunch_{project name} folder, closed VS then re-opened VS, re-opened my solution and selected 'Enable NCrunch' from the menu. The new solution wizard ran but I still have the same issue.

While I was deleting the .NCrunchproject files I noticed that in some folders there were sometimes multiple .NCrunchproject files, if for example my project had been called 'My Project' at some point and I had renamed it to 'My.Project" the there would be two .NCrunchproject files one called 'My Project.NCrunchproject" and another called "My.Project.NCrunchproject".

I noticed that the stack trace reports that I have a public key token of null where I noticed that Ralf has a public key token. Also after everything I've done the file that the stack trace is reporting it can't find is reported with it's original name not it's renamed and correct name.

I would be happy to send you a copy of my VS solution so you can see the issue for yourself if that would help. I have included a copy of my stack trace below, and submitted a bug report a few days ago. If there is anything else I can do to help please let me know.

Thanks for your help Remco and thanks for NCrunch it's awesome.

Stack trace from NCrunch Tests window.
An error occurred while analysing this project after it was built: System.IO.FileNotFoundException: Could not load file or assembly 'Recruit.Persistence Store, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null' or one of its dependencies. The system cannot find the file specified.
File name: 'Recruit.Persistence Store, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null'
at System.Reflection.RuntimeAssembly.GetExportedTypes(RuntimeAssembly assembly, ObjectHandleOnStack retTypes)
at System.Reflection.RuntimeAssembly.GetExportedTypes()
at NUnit.Core.CoreExtensions.InstallAdhocExtensions(Assembly assembly)
at NUnit.Core.Builders.TestAssemblyBuilder.Load(String path)
at NUnit.Core.Builders.TestAssemblyBuilder.Build(String assemblyName, Boolean autoSuites)
at NUnit.Core.Builders.TestAssemblyBuilder.Build(String assemblyName, String testName, Boolean autoSuites)
at NUnit.Core.TestSuiteBuilder.Build(TestPackage package)
at nCrunch.Module.NUnit.Integration.NUnitDynamicTestFinder.FindFrameworkTestsUsingRuntimeInvoke(TestPackage package, ILogger logger, List`1 tests, Factory testNameFactory)
at nCrunch.Module.NUnit.Integration.NUnitTestFramework.FindFrameworkTestsInAssembly(ReflectedAssembly assembly, FilePath assemblyFilePath, IList`1 referencedAssemblyFilePaths, ComponentUniqueName testComponentUniqueName)
at nCrunch.TestExecution.TestFinder.FindTestsForFrameworks(ReflectedAssembly assembly, FilePath assemblyFilePath, IList`1 referencedAssemblyFilePaths, TestFrameworkDescription[] frameworks, ComponentUniqueName testComponentUniqueName)
at nCrunch.TestExecution.RemoteTaskRunner.AnalyseAssembly(TestFrameworkDescription[] applicableFrameworks, ComponentUniqueName testComponentUniqueName)

=== Pre-bind state information ===
LOG: DisplayName = Recruit.Persistence Store, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null
(Fully-specified)
LOG: Appbase = file:///C:/Users/Stu/AppData/Local/NCrunch/6384/12/Recruit.UnitTests/bin/Debug
LOG: Initial PrivatePath = NULL
Hi, thanks for sharing more details on this problem. I'm wondering - when renaming your projects, did you also change the name of their output assemblies? The issue here seems to be related to the assembly name rather than the project.

I have a fix prepared for this problem and I'm expecting to release it as part of 2.9 later today. Sorry for the trouble and thanks for your patience.
Hi Remco,
No I didn't change the name of the output assemblies. To rename the projects and the files in them I just used the Rename context menu item from inside VS solution explorer.
Hi Remco,
I just installed version 2.9 and it has sorted this problem. Thanks for your help with this.

Post a reply

Log in to reply.