Skip to content

Commit 276cca6

Browse files
committed
Proof of concept using different base paths
1 parent 7bb5f37 commit 276cca6

File tree

2 files changed

+36
-10
lines changed

2 files changed

+36
-10
lines changed

src/Components/MSBuild.fs

Lines changed: 10 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ module MSBuild =
2424
| Ok msbuild -> Promise.lift msbuild
2525
| Error msg -> Promise.reject (exn msg))
2626

27-
let invokeMSBuildWithCancel project target (cancellationToken: CancellationToken) =
27+
let invokeMSBuildWithCancel project target (cancellationToken: CancellationToken) args =
2828

2929
if cancellationToken.isCancellationRequested then
3030
promise { return { Code = None; Signal = Some "SIGINT" } }
@@ -33,12 +33,17 @@ module MSBuild =
3333
let cfg = workspace.getConfiguration ()
3434
cfg.get ("FSharp.msbuildAutoshow", false)
3535

36-
let command = [ project; $"/t:%s{target}" ]
36+
let command =
37+
[
38+
project;
39+
// $"/t:%s{target}"
40+
]
41+
@ args
3742

3843
let executeWithHost () =
3944
promise {
4045
let! msbuildPath = dotnetBinary ()
41-
let cmd = ResizeArray("msbuild" :: command)
46+
let cmd = ResizeArray("build" :: command)
4247
logger.Info("invoking msbuild from %s on %s for target %s", msbuildPath, project, target)
4348

4449
if autoshow then
@@ -222,7 +227,7 @@ module MSBuild =
222227
}
223228
}
224229

225-
let buildProjectPath target (project: Project) = invokeMSBuild project.Project target
230+
let buildProjectPath target (project: Project) = invokeMSBuild project.Project target []
226231

227232
let buildProjectPathFast (project: Project) =
228233
promise {
@@ -252,7 +257,7 @@ module MSBuild =
252257

253258
p.report pm
254259

255-
invokeMSBuild path "Restore" |> Promise.bind continuation |> Promise.toThenable)
260+
invokeMSBuild path "Restore" [] |> Promise.bind continuation |> Promise.toThenable)
256261
)
257262
|> Promise.ofThenable
258263
|> Async.AwaitPromise

src/Components/TestExplorer.fs

Lines changed: 26 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -94,10 +94,21 @@ module CancellationToken =
9494

9595
tokenSource.token
9696

97+
98+
9799
type TestId = string
98100
type ProjectPath = string
99101
type TargetFramework = string
100102

103+
module Project =
104+
let testPathSubDir = ".ionide-test"
105+
let getOutputPaths () =
106+
let objOutputPath = node.path.join [| "obj" ; testPathSubDir ; node.path.sep|]
107+
let baseIntermediateOutputPath = $"/p:BaseIntermediateOutputPath={objOutputPath}"
108+
let binOutputPath = node.path.join [| "bin" ; testPathSubDir; node.path.sep |]
109+
let baseOutputPath = $"/p:BaseOutputPath={binOutputPath}"
110+
[baseIntermediateOutputPath; baseOutputPath]
111+
101112
module ProjectPath =
102113
let inline ofString str = str
103114

@@ -486,8 +497,9 @@ module DotnetCli =
486497

487498
let restore
488499
(projectPath: string)
500+
args
489501
: JS.Promise<Node.ChildProcess.ExecError option * StandardOutput * StandardError> =
490-
Process.exec "dotnet" (ResizeArray([| "restore"; projectPath |]))
502+
Process.exec "dotnet" (ResizeArray([| "restore"; projectPath; yield! args |]))
491503

492504
let private debugProcessIdRegex = RegularExpressions.Regex(@"Process Id: (.*),")
493505

@@ -621,14 +633,16 @@ module DotnetCli =
621633
promise {
622634
let additionalArgs = if not shouldBuild then [| "--no-build" |] else Array.empty
623635

636+
let basePathArgs = Project.getOutputPaths ()
637+
624638
let! _, stdOutput, _ =
625639
dotnetTest
626640
cancellationToken
627641
projectPath
628642
targetFramework
629643
None
630644
NoDebug
631-
[| "--list-tests"; yield! additionalArgs |]
645+
[| "--list-tests"; yield! additionalArgs; yield! basePathArgs; "/p:BuildProjectReferences=false" |]
632646

633647
let testNames =
634648
stdOutput
@@ -1493,8 +1507,11 @@ module Interactions =
14931507
let runnableTests = TestItem.runnableFromArray projectRunRequest.Tests
14941508

14951509
let projectPath = projectRunRequest.ProjectPath
1496-
let! _ = DotnetCli.restore projectPath
1497-
let! buildStatus = MSBuild.invokeMSBuildWithCancel projectPath "Build" _ct
1510+
let basePathArgs = Project.getOutputPaths ()
1511+
1512+
let! _ = DotnetCli.restore projectPath basePathArgs
1513+
1514+
let! buildStatus = MSBuild.invokeMSBuildWithCancel projectPath "Build" _ct basePathArgs
14981515

14991516
if buildStatus.Code <> Some 0 then
15001517
TestRun.showError testRun "Project build failed" runnableTests
@@ -1568,7 +1585,11 @@ module Interactions =
15681585
promise {
15691586
let projectPath = project.Project
15701587
logger.Info($"Building {projectPath}")
1571-
let! processExit = MSBuild.invokeMSBuildWithCancel projectPath "Build" cancellationToken
1588+
1589+
let basePathArgs = Project.getOutputPaths ()
1590+
1591+
1592+
let! processExit = MSBuild.invokeMSBuildWithCancel projectPath "Build" cancellationToken basePathArgs
15721593
return (project, processExit)
15731594
})
15741595

0 commit comments

Comments
 (0)