Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Closed
mwhelan opened this issue Aug 7, 2016 · 11 comments
Closed

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

mwhelan opened this issue Aug 7, 2016 · 11 comments
Assignees
Milestone

Comments

@mwhelan
Copy link

mwhelan commented Aug 7, 2016

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
Copy link
Owner

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

@mwhelan
Copy link
Author

mwhelan commented Aug 8, 2016

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
Copy link
Owner

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

@mwhelan
Copy link
Author

mwhelan commented Aug 8, 2016

Yes, it is.

@jcansdale
Copy link
Owner

Can I see your project.json file?

@mwhelan
Copy link
Author

mwhelan commented Aug 9, 2016

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
Copy link
Owner

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
Copy link
Author

mwhelan commented Aug 9, 2016

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 jcansdale changed the title Cannot find NUnit with .Net 4.6 tests in xproj Look for DLLs in RID directory, not just EXEs Aug 9, 2016
@jcansdale jcansdale self-assigned this Aug 9, 2016
@jcansdale jcansdale added this to the v4.0-beta milestone Aug 9, 2016
@jcansdale
Copy link
Owner

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

@jcansdale
Copy link
Owner

Seems to be working. 😄

@mwhelan
Copy link
Author

mwhelan commented Aug 9, 2016

Yup, sure does. Love your work @jcansdale !

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants