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

Test projects sometimes require <OutputType>Exe</OutputType> #191

Closed
NTaylorMullen opened this issue Nov 7, 2016 · 7 comments
Closed

Test projects sometimes require <OutputType>Exe</OutputType> #191

NTaylorMullen opened this issue Nov 7, 2016 · 7 comments

Comments

@NTaylorMullen
Copy link

Description

Migrating existing test projects from project.json => csproj results in class library based test projects. The problem with this is trying to run dotnet test fails. This doesn't always seem to be a problem because I've also migrated more complex projects that look to work without the <OutputType>Exe</OutputType> requirement (added a repro project to show where it does fail).

Steps to reproduce

Expected behavior

Microsoft (R) Test Execution Command Line Tool Version 15.0.0.0
Copyright (c) Microsoft Corporation.  All rights reserved.

Starting test execution, please wait...
Passed   Tests.Tests.Test1

Total tests: 1. Passed: 1. Failed: 0. Skipped: 0.
Test Run Successful.
Test execution time: 1.9826 Seconds

Actual behavior

Microsoft (R) Test Execution Command Line Tool Version 15.0.0.0
Copyright (c) Microsoft Corporation.  All rights reserved.

Starting test execution, please wait...
Error: Could not find testhost.dll for source 'C:\Users\nimullen\Documents\temp\TestMigrationProject\bin\Debug\netcoreapp1.1\TestMigrationProject.dll'. Make sure test project has a nuget reference of package "microsoft.testplatform.testhost".

Environment

dotnet --info:

.NET Command Line Tools (1.0.0-preview3-004056)

Product Information:
 Version:            1.0.0-preview3-004056
 Commit SHA-1 hash:  ccc4968bc3

Runtime Environment:
 OS Name:     Windows
 OS Version:  10.0.14393
 OS Platform: Windows
 RID:         win10-x64

Microsoft.NET.Test.Sdk version tested:
15.0.0-preview-20161024-02

@natemcmaster
Copy link
Contributor

natemcmaster commented Dec 14, 2016

I hit this too. It seems .NET Framework tests will run when <OutputType> is missing, but .NET Core tests fail as Taylor described. Using 15.0.0-preview-20161123-03.

@codito
Copy link
Contributor

codito commented Dec 15, 2016

This issue is by design. A multitargeted test project should have following structure:

<OutputType Condition=" '$(TargetFramework)' != 'net46' ">Exe</OutputType>
<TargetFrameworks>net46;netcoreapp1.0;netcoreapp1.1</TargetFrameworks>

netXX test projects have always been libraries. netcoreapp test projects need to exe as per dotnet/sdk#201.

@natemcmaster
Copy link
Contributor

Would it make sense to put something like this in Microsoft.NET.Test.SDK?

<OutputType Condition=" $(TargetFramework.StartsWith('netcoreapp') ">Exe</OutputType>

@NTaylorMullen
Copy link
Author

NTaylorMullen commented Dec 15, 2016

Why do desktop targeting test projects need to be console applications? In the past a test project did not need to be a console application in order to work.

@natemcmaster
Copy link
Contributor

natemcmaster commented Dec 15, 2016 via email

@codito
Copy link
Contributor

codito commented Dec 17, 2016

Created #287 as an umbrella issue for discussing the options around this.

@codito
Copy link
Contributor

codito commented Dec 21, 2016

Closing this in favor of #287

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

3 participants