jcansdale / TestDriven.Net-Issues

Issue tracking for TestDriven.Net
https://github.com/jcansdale/TestDriven.Net-Issues/issues
24 stars 2 forks source link

Look for DLLs in RID directory, not just EXEs #37

Closed mwhelan closed 8 years ago

mwhelan commented 8 years ago

My xproj test project targets netcoreapp1.0 and net46 (project.json defines them in that order). I have some tests that use a dependency that is only net46 so I am using #if directives to make it compile:

    public class SemanticVersioningTests
    {
#if NET46
        [Test]
        public void specify_has_no_public_api_changes()
        {
            var publicApi = PublicApiGenerator.PublicApiGenerator.GetPublicApi(typeof(IScenario).Assembly);
            publicApi.ShouldMatchApproved();
        }

        [Test]
        public void specify_autofac_has_no_public_api_changes()
        {
            var publicApi = PublicApiGenerator.PublicApiGenerator.GetPublicApi(typeof(AutofacContainer).Assembly);
            publicApi.ShouldMatchApproved();
        }
#endif
    }

When I right click the file and choose Test with > .Net Framework, I get the following error:

System.IO.FileNotFoundException: Could not load file or assembly 'nunit.framework, Version=3.4.1.0, Culture=neutral, PublicKeyToken=2638cd05610744eb' or one of its dependencies. The system cannot find the file specified.
File name: 'nunit.framework, Version=3.4.1.0, Culture=neutral, PublicKeyToken=2638cd05610744eb'
   at System.ModuleHandle.ResolveType(RuntimeModule module, Int32 typeToken, IntPtr* typeInstArgs, Int32 typeInstCount, IntPtr* methodInstArgs, Int32 methodInstCount, ObjectHandleOnStack type)
   at System.ModuleHandle.ResolveTypeHandleInternal(RuntimeModule module, Int32 typeToken, RuntimeTypeHandle[] typeInstantiationContext, RuntimeTypeHandle[] methodInstantiationContext)
   at System.Reflection.RuntimeModule.ResolveType(Int32 metadataToken, Type[] genericTypeArguments, Type[] genericMethodArguments)
   at 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)
   at System.Reflection.CustomAttribute.GetCustomAttributes(RuntimeModule decoratedModule, Int32 decoratedMetadataToken, Int32 pcaCount, RuntimeType attributeFilterType, Boolean mustBeInheritable, IList derivedAttributes, Boolean isDecoratedTargetSecurityTransparent)
   at System.Reflection.CustomAttribute.GetCustomAttributes(RuntimeMethodInfo method, RuntimeType caType, Boolean inherit)
   at Polyfills.ReflectionPolyfill.GetCustomAttributes(MemberInfo member)
   at TestDriven.NetCore.TestRunnerFactory.hasCustomAttributes(MemberInfo member)
   at TestDriven.NetCore.TestRunnerFactory.useAdHoc(MemberInfo member)
   at TestDriven.NetCore.TestRunnerFactory.Create(ITestListener testListener, String assemblyFile, String cref, TestRunnerTarget& target)
   at TestDriven.NetCore.Program.run(String assemblyFile, String cref)
   at TestDriven.NetCore.Program.Remote.Run(String assemblyFile, String cref)

WRN: Assembly binding logging is turned OFF.
To enable assembly bind failure logging, set the registry value [HKLM\Software\Microsoft\Fusion!EnableLog] (DWORD) to 1.
Note: There is some performance penalty associated with assembly bind failure logging.
To turn this feature off, remove the registry value [HKLM\Software\Microsoft\Fusion!EnableLog].
jcansdale commented 8 years ago

That's strange! Is there a dotnet-test-nunit.exe but no nunit.framework.dll in your output directory?

mwhelan commented 8 years ago

My folder structure is Debug\net46\win7-x64. That folder contains both dotnet-test-nunit.exe and nunit.framework.dll. Interestingly, Specify.Tests.dll (the project being tested) is in the net46 folder, while all the other dlls are in the win7-x64 folder.

jcansdale commented 8 years ago

Could you check that nunit.framework.dll is v3.4.1?

mwhelan commented 8 years ago

Yes, it is.

jcansdale commented 8 years ago

Can I see your project.json file?

mwhelan commented 8 years ago

Yes, it is here. You can run the Specify.Tests project. In particular it is the APIs\SemanticVersioningTests.cs. I don't know if the #if directives are somehow influential.

jcansdale commented 8 years ago

Got it, thanks!

It looks like I'm making the incorrect assumption that apps that target "netcoreapp1.0" must have an entry point / be EXE files when compiled for .NET. It appears they don't actually have to be a console application (this just happens to be the way they're set up in the .NET Core project templates).

Hopefully this is simply a question of how I search for the .NET Framework assembly. I need to find the one in bin\Debug\net46\win7-x64 not bin\Debug\net46.

mwhelan commented 8 years ago

Have to admit, I'm quite hazy on the difference between console projects and class library ones. For example, if I created a class library, and then realised it should be a console app, can I edit the xproj or something? (apart from adding a main method, etc.). I don't think there is an option in the VS tooling in project properties.

jcansdale commented 8 years ago

Could you give this build a try: TestDriven.NET-4.0.3356_Extraterrestrial_Alpha.zip

jcansdale commented 8 years ago

Seems to be working. :smile:

mwhelan commented 8 years ago

Yup, sure does. Love your work @jcansdale !