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

Error when running with an x86 csproj #23

Closed
glen-nicol opened this issue Feb 27, 2018 · 14 comments · Fixed by #61
Closed

Error when running with an x86 csproj #23

glen-nicol opened this issue Feb 27, 2018 · 14 comments · Fixed by #61
Assignees
Milestone

Comments

@glen-nicol
Copy link

glen-nicol commented Feb 27, 2018

I get an error when I try and run my x86 bound Nunit project with the console runner along with another Any CPU project in a solution. I specify the project files individually because when I use the solution it complains about the actual projects being portable class libraries among other things.

I can run both of these projects just fine as is with the Visual studio adapter. I also tried to run the console without the Any CPU test project and I get the same error for the .csproj. If I specify the path to the built test assembly it runs just fine.

Any ideas on why it would have trouble with a project that only has a x86 platform target?

packages\NUnit.ConsoleRunner.3.8.0\tools\nunit3-console.exe  <Path to ANY CPU test projectfile>.csproj  <Path to x86 test projectfile>.csproj  --config=Release --x86
NUnit Console Runner 3.8.0
Copyright (c) 2018 Charlie Poole, Rob Prouse

Runtime Environment
   OS Version: Microsoft Windows NT 6.1.7601 Service Pack 1
  CLR Version: 4.0.30319.42000

Test Files
    <Path to ANY CPU test projectfile>.csproj
    <Path to x86 test projectfile>.csproj


Errors, Failures and Warnings

1) Invalid : <Path to x86 test projectfile>.csproj
File type is not supported

Run Settings
    BasePath: REDACTED
    RunAsX86: True
    DisposeRunners: True
    ActiveConfig: Release
    WorkDirectory: REDACTED
    ImageRuntimeVersion: 4.0.30319
    ImageTargetFrameworkName: .NETFramework,Version=v4.6.2
    ImageRequiresX86: False
    ImageRequiresDefaultAppDomainAssemblyResolver: False
    NumberOfTestWorkers: 8

Test Run Summary
  Overall result: Failed
  Test Count: 30, Passed: 30, Failed: 0, Warnings: 0, Inconclusive: 0, Skipped: 0
  Start time: 2018-02-27 18:14:22Z
    End time: 2018-02-27 18:14:24Z
    Duration: 1.590 seconds

Results (nunit3) saved as TestResult.xml
NMAKE : fatal error U1077: 'packages\NUnit.ConsoleRunner.3.8.0\tools\nunit3-console.exe' : return code '0xfffffffc'
Stop.

@CharliePoole
Copy link
Contributor

CharliePoole commented Feb 27, 2018

As indicated in the displayed settings, your use of the --x86 option is telling the console runner that all the assemblies should be run as x86. I believe that simply leaving off the option should solve the problem.

Use of a -csproj file on the command-line is equivalent to using the output assembly for the default config or the one you specify. NUnit will examine the assembly and will generally be able to figure out how it needs to be run.

Closing this as an answered question. Feel free to ask for follow-up as we will see it and respond.

@glen-nicol
Copy link
Author

I get the same error if I remove the --x86 option.

@ChrisMaddock
Copy link
Member

That’s an odd error message for this problem. Can you share the testresult.xml file?

@CharliePoole
Copy link
Contributor

@ChrisMaddock You're right. That's the result you would normally get if the vs-project-loader extension were not availble. It's as if it's available for one of them and not for the other. I wonder if this is a regression for when multiple projects are specified in the command-line?

@glen-nicol what if you specify the two assembly paths?

@glen-nicol
Copy link
Author

@ChrisMaddock I can probably share snippets of the results. Is there something in particular you want to see?
@CharliePoole specifying both assembly paths works.

@CharliePoole
Copy link
Contributor

I think it may be an engine or console issue. Let's examine further before moving.

More than one project on the command line was a new feature in NUnit 3. IIRC we had some issues and fixed them.

@glen-nicol can you run multiple IL only projects?

@CharliePoole CharliePoole reopened this Feb 28, 2018
@glen-nicol
Copy link
Author

So I added an IL platform to the x86 assembly. Which is fine, I really just specify x86 to ensure visual studio runs the tests as a 32 bit process because it calls into a native dll that is 32bit.

It picks up the IL path and tries to find the assembly in \bin\Release instead of \bin\x86\release. If I build the project for IL then the tests run just fine. But it definitely seems like the engine is not interpreting the x86 path correctly. I can understand it not necessarily being able to determine between the two platforms when they are both there without the solution but if it is just x86 I think it should still work.

Is there a way to point it at my solution and then give it a filter for the projects? like

console.exe solution.sln -=filter=*.Tests

That way it can actually read the configuration manager data to determine the correct paths to use for the configuration and platform?

@CharliePoole
Copy link
Contributor

@glen-nicol In that case, it really may be a problem with the project loader. The basic question is whether the project loader has to deduce the path or if it's fully spelled out in the project file. Perhaps you can post some or all of your project file so we can try to replicate this.

@CharliePoole
Copy link
Contributor

@glen-nicol Unfortunately, there is no filtering when loading tests in a project file. Nice idea though.

@glen-nicol
Copy link
Author

Here is the project file.

<?xml version="1.0" encoding="utf-8"?>
<Project ToolsVersion="14.0" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
  <Import Project="..\packages\NUnit3TestAdapter.3.9.0\build\net35\NUnit3TestAdapter.props" Condition="Exists('..\packages\NUnit3TestAdapter.3.9.0\build\net35\NUnit3TestAdapter.props')" />
  <Import Project="$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props" Condition="Exists('$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props')" />
  <PropertyGroup>
    <Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
    <Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
    <ProjectGuid>{8EDF4429-251A-416D-BB68-93F227191BCF}</ProjectGuid>
    <OutputType>Library</OutputType>
    <AppDesignerFolder>Properties</AppDesignerFolder>
    <RootNamespace>DD.Net_46.Tests</RootNamespace>
    <AssemblyName>DD.Net_46.Tests</AssemblyName>
    <TargetFrameworkVersion>v4.6.2</TargetFrameworkVersion>
    <FileAlignment>512</FileAlignment>
    <TargetFrameworkProfile />
    <NuGetPackageImportStamp>8dc73fc5</NuGetPackageImportStamp>
  </PropertyGroup>
  <PropertyGroup Condition="'$(Configuration)|$(Platform)' == 'Debug|x86'">
    <DebugSymbols>true</DebugSymbols>
    <OutputPath>bin\x86\Debug\</OutputPath>
    <DefineConstants>DEBUG;TRACE</DefineConstants>
    <DebugType>full</DebugType>
    <PlatformTarget>x86</PlatformTarget>
    <ErrorReport>prompt</ErrorReport>
    <CodeAnalysisRuleSet>MinimumRecommendedRules.ruleset</CodeAnalysisRuleSet>
  </PropertyGroup>
  <PropertyGroup Condition="'$(Configuration)|$(Platform)' == 'Release|x86'">
    <OutputPath>bin\x86\Release\</OutputPath>
    <DefineConstants>TRACE</DefineConstants>
    <Optimize>true</Optimize>
    <DebugType>pdbonly</DebugType>
    <PlatformTarget>x86</PlatformTarget>
    <ErrorReport>prompt</ErrorReport>
    <CodeAnalysisRuleSet>MinimumRecommendedRules.ruleset</CodeAnalysisRuleSet>
  </PropertyGroup>
  <ItemGroup>
    <!-- a couple redacted assembly references -->
    <Reference Include="Nito.AsyncEx, Version=3.0.1.0, Culture=neutral, processorArchitecture=MSIL">
      <HintPath>..\packages\Nito.AsyncEx.3.0.1\lib\net45\Nito.AsyncEx.dll</HintPath>
      <Private>True</Private>
    </Reference>
    <Reference Include="Nito.AsyncEx.Concurrent, Version=3.0.1.0, Culture=neutral, processorArchitecture=MSIL">
      <HintPath>..\packages\Nito.AsyncEx.3.0.1\lib\net45\Nito.AsyncEx.Concurrent.dll</HintPath>
      <Private>True</Private>
    </Reference>
    <Reference Include="Nito.AsyncEx.Enlightenment, Version=3.0.1.0, Culture=neutral, processorArchitecture=MSIL">
      <HintPath>..\packages\Nito.AsyncEx.3.0.1\lib\net45\Nito.AsyncEx.Enlightenment.dll</HintPath>
      <Private>True</Private>
    </Reference>
    <Reference Include="nunit.framework, Version=3.6.1.0, Culture=neutral, PublicKeyToken=2638cd05610744eb, processorArchitecture=MSIL">
      <HintPath>..\packages\NUnit.3.6.1\lib\net45\nunit.framework.dll</HintPath>
      <Private>True</Private>
    </Reference>
    <Reference Include="System" />
    <Reference Include="System.Threading.Tasks.Dataflow, Version=4.5.24.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a, processorArchitecture=MSIL">
      <HintPath>..\packages\Microsoft.Tpl.Dataflow.4.5.24\lib\portable-net45+win8+wpa81\System.Threading.Tasks.Dataflow.dll</HintPath>
      <Private>True</Private>
    </Reference>
  </ItemGroup>
  <ItemGroup>
    <!-- Can't share these files so I commented them out for you. -->
    <!-- <Compile Include="DDBasicNativeMethodTests.cs" />
    <Compile Include="FactoryTests.cs" /> -->
    <Compile Include="Properties\AssemblyInfo.cs" />
  </ItemGroup>
  <ItemGroup>
    <None Include="packages.config" />
  </ItemGroup>
  <ItemGroup>
    <ProjectReference Include="..\DD.Net.Abstractions\DD.Net.Abstractions.csproj">
      <Project>{55b1d427-edbe-4546-8805-ebadaed1cf86}</Project>
      <Name>DD.Net.Abstractions</Name>
    </ProjectReference>
    <ProjectReference Include="..\DD.Net_46\DD.Net_46.csproj">
      <Project>{94761d8d-857b-4f11-959a-3b41236876e7}</Project>
      <Name>DD.Net_46</Name>
    </ProjectReference>
  </ItemGroup>
  <ItemGroup>
    <Service Include="{82A7F48D-3B50-4B1E-B82E-3ADA8210C358}" />
  </ItemGroup>
  <Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
  <Target Name="EnsureNuGetPackageBuildImports" BeforeTargets="PrepareForBuild">
    <PropertyGroup>
      <ErrorText>This project references NuGet package(s) that are missing on this computer. Enable NuGet Package Restore to download them.  For more information, see http://go.microsoft.com/fwlink/?LinkID=322105. The missing file is {0}.</ErrorText>
    </PropertyGroup>
    <Error Condition="!Exists('..\packages\NUnit3TestAdapter.3.9.0\build\net35\NUnit3TestAdapter.props')" Text="$([System.String]::Format('$(ErrorText)', '..\packages\NUnit3TestAdapter.3.9.0\build\net35\NUnit3TestAdapter.props'))" />
    <Error Condition="!Exists('..\packages\StyleCop.MSBuild.5.0.0\build\StyleCop.MSBuild.targets')" Text="$([System.String]::Format('$(ErrorText)', '..\packages\StyleCop.MSBuild.5.0.0\build\StyleCop.MSBuild.targets'))" />
  </Target>
  <Import Project="..\packages\StyleCop.MSBuild.5.0.0\build\StyleCop.MSBuild.targets" Condition="Exists('..\packages\StyleCop.MSBuild.5.0.0\build\StyleCop.MSBuild.targets')" />
  <!-- To modify your build process, add your task inside one of the targets below and uncomment it. 
       Other similar extension points exist, see Microsoft.Common.targets.
  <Target Name="BeforeBuild">
  </Target>
  <Target Name="AfterBuild">
  </Target>
  -->
</Project>

And here are the nuget packages.

<?xml version="1.0" encoding="utf-8"?>
<packages>
        <!-- Same redacted packages -->
	<package id="Microsoft.Tpl.Dataflow" version="4.5.24" targetFramework="net462" />
	<package id="Nito.AsyncEx" version="3.0.1" targetFramework="net462" />
	<package id="NUnit" version="3.6.1" targetFramework="net45" />
	<package id="NUnit3TestAdapter" version="3.9.0" targetFramework="net462" />
	<package id="StyleCop.MSBuild" version="5.0.0" targetFramework="net462" developmentDependency="true" />
</packages>

@CharliePoole
Copy link
Contributor

After "stepping" mentally through the source code, I concluded that it should work. 😄

My best guess is that the message indicating that .csproj is an unknown file type is spurious and is caused by some exception being thrown by the loader when reading your file. One of us will have to actually step through this in the debugger to come up with anything more certain.

At the moment, I'm onto some other work so I'll leave this unassigned.

@ChrisMaddock ChrisMaddock changed the title Cannot run Error when running with an x86 csproj Jul 20, 2018
@CharliePoole CharliePoole self-assigned this Sep 12, 2021
@CharliePoole CharliePoole added this to the 3.9 milestone Sep 12, 2021
@CharliePoole
Copy link
Contributor

This appears to be very similar to issue #34, which is fixed and now passes its tests correctly. See the closing comment on that issue.

@glen-nicol Can you try out the dev package linked from that issue and let us know if it works for you?

@CharliePoole
Copy link
Contributor

To be really sure this was resolved, I added a unit test based on your sample project file with only x86 platform.

@CharliePoole
Copy link
Contributor

🎉 This issue has been resolved in version 3.9.0 🎉

The release is available on:

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

Successfully merging a pull request may close this issue.

3 participants