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

Explicit RID still required for .NET Framework test projects #909

Closed
natemcmaster opened this issue Feb 24, 2017 · 8 comments
Closed

Explicit RID still required for .NET Framework test projects #909

natemcmaster opened this issue Feb 24, 2017 · 8 comments

Comments

@natemcmaster
Copy link
Contributor

RID inference for .NET Framework is conditioned on 'OutputType=exe'. Test projects, however, may still be "executable" even if compile as a library.

This means test projects for .NET Framework with native assets will fail. Either need a RID or users need to set OutputType=exe, which is not the default template setting.

Repro

<Project Sdk="Microsoft.NET.Sdk">

  <PropertyGroup>
    <TargetFramework>net46</TargetFramework>
  </PropertyGroup>

  <ItemGroup>
    <PackageReference Include="Microsoft.Data.Sqlite" Version="1.1.0" />
    <PackageReference Include="Microsoft.NET.Test.Sdk" Version="15.0.0" />
    <PackageReference Include="xunit" Version="2.2.0" />
    <PackageReference Include="xunit.runner.visualstudio" Version="2.2.0" />
  </ItemGroup>

</Project>
using Microsoft.Data.Sqlite;
using Xunit;

public class SqliteConnectionTest
{
    [Fact]
    public void OpensConnection()
    {
        new SqliteConnection("Data Source=:memory:").Open();
    }
}

dotnet restore
dotnet test

Expected
Infers RID to win7-x86/x64 and test work :)

Actual
Tests build, but fail because the native component "sqlite3.dll" is missing from build output.

[xUnit.net 00:00:00.8776695]     SqliteConnectionTest.OpensConnection [FAIL]
[xUnit.net 00:00:00.8784311]       System.DllNotFoundException : Unable to load DLL 'sqlite3': The specified module could not be found. (Exception from HRESULT: 0x8007007E)

Details
dotnet --version: 1.0.0-rc4-004883

Workarounds
Add a <RuntimeIdentifier> or set <OutputType>exe</OutputType>.

@eerhardt
Copy link
Member

eerhardt commented Apr 6, 2017

Adding Blocking Partner since I just "closed as duplicate" an issue that was Blocking Partner.

@livarcocc
Copy link
Contributor

@nguerrera this is the issue we chatted about before. Take a look when you have time.

@nguerrera
Copy link
Contributor

This will be fixed by #1178 once the test project sets HasRuntimeOutput to true, which is now tracked by microsoft/vstest#792

@natemcmaster
Copy link
Contributor Author

natemcmaster commented May 19, 2017

This is not fixed by #1178. Even if you add HasRuntimeOutput to the test project, you still need the explicit RID.

Repro

<Project Sdk="Microsoft.NET.Sdk">

  <PropertyGroup>
    <TargetFramework>net46</TargetFramework>
    <HasRuntimeOutput>true</HasRuntimeOutput>
  </PropertyGroup>

  <ItemGroup>
    <PackageReference Include="Microsoft.Data.Sqlite" Version="1.1.0" />
    <PackageReference Include="Microsoft.NET.Test.Sdk" Version="15.3.0-*" />
    <PackageReference Include="xunit" Version="2.2.0" />
    <PackageReference Include="xunit.runner.visualstudio" Version="2.2.0" />
  </ItemGroup>

</Project>
using Microsoft.Data.Sqlite;
using Xunit;

public class SqliteConnectionTest
{
    [Fact]
    public void OpensConnection()
    {
        new SqliteConnection("Data Source=:memory:").Open();
    }
}

dotnet SDK 2.0.0-preview2-006098

Result

System.DllNotFoundException : Unable to load DLL 'sqlite3':

Workdaround
add explicit rid

<RuntimeIdentifier>win7-x64</RuntimeIdentifier>

@natemcmaster natemcmaster reopened this May 19, 2017
@natemcmaster
Copy link
Contributor Author

@nguerrera is this just because latest CLI hasn't ingested the SDK?

@nguerrera
Copy link
Contributor

I think so. I'll check.

@nguerrera
Copy link
Contributor

Yes, that was it. dotnet/cli#6665 is out to update the SDK in the CLI.

@natemcmaster
Copy link
Contributor Author

Thanks @nguerrera

analogrelay added a commit to aspnet/WebSockets that referenced this issue May 25, 2017
vdex42 pushed a commit to Aqovia/Aqovia.PactProducerVerifier.AspNetCore that referenced this issue Nov 29, 2017
mmitche pushed a commit to mmitche/sdk that referenced this issue Jun 5, 2020
…826.12 (dotnet#909)

- Microsoft.DotNet.Arcade.Sdk - 1.0.0-beta.19426.12
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

5 participants