diff --git a/src/Components/MSBuild.fs b/src/Components/MSBuild.fs index 5c685048..0e953ca9 100644 --- a/src/Components/MSBuild.fs +++ b/src/Components/MSBuild.fs @@ -24,7 +24,7 @@ module MSBuild = | Ok msbuild -> Promise.lift msbuild | Error msg -> Promise.reject (exn msg)) - let invokeMSBuildWithCancel project target (cancellationToken: CancellationToken) = + let invokeMSBuildWithCancel project target (cancellationToken: CancellationToken) args = if cancellationToken.isCancellationRequested then promise { return { Code = None; Signal = Some "SIGINT" } } @@ -33,12 +33,17 @@ module MSBuild = let cfg = workspace.getConfiguration () cfg.get ("FSharp.msbuildAutoshow", false) - let command = [ project; $"/t:%s{target}" ] + let command = + [ + project; + // $"/t:%s{target}" + ] + @ args let executeWithHost () = promise { let! msbuildPath = dotnetBinary () - let cmd = ResizeArray("msbuild" :: command) + let cmd = ResizeArray("build" :: command) logger.Info("invoking msbuild from %s on %s for target %s", msbuildPath, project, target) if autoshow then @@ -222,7 +227,7 @@ module MSBuild = } } - let buildProjectPath target (project: Project) = invokeMSBuild project.Project target + let buildProjectPath target (project: Project) = invokeMSBuild project.Project target [] let buildProjectPathFast (project: Project) = promise { @@ -252,7 +257,7 @@ module MSBuild = p.report pm - invokeMSBuild path "Restore" |> Promise.bind continuation |> Promise.toThenable) + invokeMSBuild path "Restore" [] |> Promise.bind continuation |> Promise.toThenable) ) |> Promise.ofThenable |> Async.AwaitPromise diff --git a/src/Components/TestExplorer.fs b/src/Components/TestExplorer.fs index f93aac27..755837bf 100644 --- a/src/Components/TestExplorer.fs +++ b/src/Components/TestExplorer.fs @@ -94,10 +94,21 @@ module CancellationToken = tokenSource.token + + type TestId = string type ProjectPath = string type TargetFramework = string +module Project = + let testPathSubDir = ".ionide-test" + let getOutputPaths () = + let objOutputPath = node.path.join [| "obj" ; testPathSubDir ; node.path.sep|] + let baseIntermediateOutputPath = $"/p:BaseIntermediateOutputPath={objOutputPath}" + let binOutputPath = node.path.join [| "bin" ; testPathSubDir; node.path.sep |] + let baseOutputPath = $"/p:BaseOutputPath={binOutputPath}" + [baseIntermediateOutputPath; baseOutputPath] + module ProjectPath = let inline ofString str = str @@ -486,8 +497,9 @@ module DotnetCli = let restore (projectPath: string) + args : JS.Promise = - Process.exec "dotnet" (ResizeArray([| "restore"; projectPath |])) + Process.exec "dotnet" (ResizeArray([| "restore"; projectPath; yield! args |])) let private debugProcessIdRegex = RegularExpressions.Regex(@"Process Id: (.*),") @@ -621,6 +633,8 @@ module DotnetCli = promise { let additionalArgs = if not shouldBuild then [| "--no-build" |] else Array.empty + let basePathArgs = Project.getOutputPaths () + let! _, stdOutput, _ = dotnetTest cancellationToken @@ -628,7 +642,7 @@ module DotnetCli = targetFramework None NoDebug - [| "--list-tests"; yield! additionalArgs |] + [| "--list-tests"; yield! additionalArgs; yield! basePathArgs; "/p:BuildProjectReferences=false" |] let testNames = stdOutput @@ -1493,8 +1507,11 @@ module Interactions = let runnableTests = TestItem.runnableFromArray projectRunRequest.Tests let projectPath = projectRunRequest.ProjectPath - let! _ = DotnetCli.restore projectPath - let! buildStatus = MSBuild.invokeMSBuildWithCancel projectPath "Build" _ct + let basePathArgs = Project.getOutputPaths () + + let! _ = DotnetCli.restore projectPath basePathArgs + + let! buildStatus = MSBuild.invokeMSBuildWithCancel projectPath "Build" _ct basePathArgs if buildStatus.Code <> Some 0 then TestRun.showError testRun "Project build failed" runnableTests @@ -1568,7 +1585,11 @@ module Interactions = promise { let projectPath = project.Project logger.Info($"Building {projectPath}") - let! processExit = MSBuild.invokeMSBuildWithCancel projectPath "Build" cancellationToken + + let basePathArgs = Project.getOutputPaths () + + + let! processExit = MSBuild.invokeMSBuildWithCancel projectPath "Build" cancellationToken basePathArgs return (project, processExit) })