With .Net Core 1.0, Working DIrectory is IDE folder whereas with .Net framework, it is System32 folder.
File -> New -> Test -> Unit test project:
When test app targets only .NET Core 1.0:
Directory.GetCurrentDirectory() = C:\Program Files (x86)\Microsoft Visual Studio\2017\Enterprise\Common7\IDE
When test app targets both .NET core 1.0 and .NET Framwork:
(
Directory.GetCurrentDirectory() = C:\Windows\system32
Expected Working Directory should be the directory where the test binary is. Since TestResults folder, or TRX files or Code Coverage files are generated relative to working directory, this is required to be "Test binary" directory. Also, Compat.
Actual is "system32" or "IDE" folder
I am seeing same problem.
test host used is: C:\Users\Darrell\.nuget\packages\microsoft.testplatform.testhost\15.0.0-preview-20170125-04\lib\netstandard1.5\testhost.dll
Directory.GetCurrentDirectory() is: C:\Program Files (x86)\Microsoft Visual Studio\2017\Community\Common7\IDE
I am using xunit 2.2.0 and xunit.runner.visualstudio 2.2.0
@dazinator Can you please try Microsoft.NET.Test.Sdk: 15.0.0. It should work for run scenarios, For debug scenario, .Net Core project WorkingDirectory comes as "C:\Windows\System32" for which bug is tracking for VS 15.1.
@smadala i tested out Microsoft.NET.Test.Sdk: 15.0.0 and experienced the same issue. On running units tests from the MS Visual Studio 17 gui Directory.GetCurrentDirectory() is still C:\Program Files (x86)\Microsoft Visual Studio\2017\Community\Common7\IDE. When i use the cmdline tool the current directory is resolved correctly.
@kdrblkbs
hello @singhsarab
i am using MS Visual Studio Enterprise 2017 15.0.0-RTW+ 26228.4. The framework target of my test project is .NETCoreApp 1.0. I am using xunit 2.2.0 and xunit.runner.visualstudio 2.2.0, too. and the final answer is yes.
regards
This is interesting, as I tested this scenario and it works fine.
Can you please try the following commandline
"C:\Program Files (x86)\Microsoft Visual Studio\2017\Enterprise\Common7\IDE\Extensions\TestPlatform\vstest.console.exe" pathToTestDll /framework:".NetCoreApp,Version=1.0"
@singhsarab its working now. i guess i was relying on the debug mode to check the result of GetCurrentDirectory() conveniently. If it is relevant in my case it is still C:\Program Files (x86)\Microsoft Visual Studio\2017\Community\Common7\IDE and not C:\Windows\System32. thanks and regards
In VS 2017 release, It seems that Directory.GetCurrentDirectory() returns C:\Program Files (x86)\Microsoft Visual Studio\2017\Community\Common7\IDE when debugging tests, but otherwise returns the test project's debug directory, aka {project_path}\bin\Debug.
Is this intended? Because it doesn't look like it's intended.
@cwharris Yes, you are right,It is a bug, has been fixed, fix will be available VS 2017 update 1.
Most helpful comment
@cwharris Yes, you are right,It is a bug, has been fixed, fix will be available VS 2017 update 1.