-
Notifications
You must be signed in to change notification settings - Fork 328
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Fix running self-contained apps on Windows (#2358)
* Copy testhost to the output directory to allow self-contained apps to run (on Windows) * Add tests for self-contained app
- Loading branch information
Showing
8 changed files
with
107 additions
and
24 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
32 changes: 32 additions & 0 deletions
32
test/Microsoft.TestPlatform.AcceptanceTests/SelfContainedAppTests.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
// Copyright (c) Microsoft Corporation. All rights reserved. | ||
// Licensed under the MIT license. See LICENSE file in the project root for full license information. | ||
|
||
namespace Microsoft.TestPlatform.AcceptanceTests | ||
{ | ||
using Microsoft.VisualStudio.TestTools.UnitTesting; | ||
using System; | ||
|
||
[TestClass] | ||
public class SelfContainedAppTests : AcceptanceTestBase | ||
{ | ||
[TestMethod] | ||
// this is core 3.1 only, full framework and netcoreapp2.1 don't "publish" automatically during build | ||
// but if you run it on 2.1 it will pass because we execute the test normally | ||
[NetCoreTargetFrameworkDataSource(useDesktopRunner: false, useNetCore21Target: false, useNetCore31Target: true)] | ||
public void RunningApplicationThatIsBuiltAsSelfContainedWillNotFailToFindHostpolicyDll(RunnerInfo runnerInfo) | ||
{ | ||
// when the application is self-contained which is dictated by the RuntimeIdentifier and OutputType project | ||
// properties, the testhost.exe executable is given a runtimeconfig that instructs it to find a hostpolicy.dll and hostfxr.dll next to it | ||
// that will fail if we run the testhost.exe from the .nuget location, but will work when we run it from the output folder | ||
// see https://github.com/dotnet/runtime/issues/3569#issuecomment-595820524 and below for description of how it works | ||
AcceptanceTestBase.SetTestEnvironment(this.testEnvironment, runnerInfo); | ||
|
||
// the app is published to win10-x64 because of the runtime identifier in the project | ||
var assemblyPath = this.BuildMultipleAssemblyPath(@"win10-x64\SelfContainedAppTestProject.dll").Trim('\"'); | ||
var arguments = PrepareArguments(assemblyPath, null, null, this.FrameworkArgValue, runnerInfo.InIsolationValue); | ||
this.InvokeVsTest(arguments); | ||
|
||
this.ValidateSummaryStatus(passedTestsCount: 1, 0, 0); | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Binary file added
BIN
+1.95 KB
test/TestAssets/SelfContainedAppTestProject/SelfContainedAppTestProject.csproj
Binary file not shown.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
using Microsoft.VisualStudio.TestTools.UnitTesting; | ||
|
||
namespace SelfContainedAppTestProject | ||
{ | ||
[TestClass] | ||
public class UnitTest1 | ||
{ | ||
[TestMethod] | ||
public void TestMethod1() | ||
{ | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters