-
-
Notifications
You must be signed in to change notification settings - Fork 294
Proof of concept using different base paths #2079
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
base: main
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -94,10 +94,21 @@ module CancellationToken = | |
|
||
tokenSource.token | ||
|
||
|
||
|
||
type TestId = string | ||
type ProjectPath = string | ||
type TargetFramework = string | ||
|
||
module Project = | ||
let testPathSubDir = ".ionide-test" | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. idea: consider using |
||
let getOutputPaths () = | ||
let objOutputPath = node.path.join [| "obj" ; testPathSubDir ; node.path.sep|] | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Using relative paths means it can build each respective project in its own subfolder (Real lib and test project), otherwise, things like project.assets.json will collide. . Though I'm not entirely sure this is the correct approach. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. using separate subfolders is the right move here IMO There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This is the same discussion that's going on for the |
||
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<Node.ChildProcess.ExecError option * StandardOutput * StandardError> = | ||
Process.exec "dotnet" (ResizeArray([| "restore"; projectPath |])) | ||
Process.exec "dotnet" (ResizeArray([| "restore"; projectPath; yield! args |])) | ||
|
||
let private debugProcessIdRegex = RegularExpressions.Regex(@"Process Id: (.*),") | ||
|
||
|
@@ -621,14 +633,16 @@ module DotnetCli = | |
promise { | ||
let additionalArgs = if not shouldBuild then [| "--no-build" |] else Array.empty | ||
|
||
let basePathArgs = Project.getOutputPaths () | ||
|
||
let! _, stdOutput, _ = | ||
dotnetTest | ||
cancellationToken | ||
projectPath | ||
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) | ||
}) | ||
|
||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We're doing the classic calling
msbuild t:Build
here instead ofdotnet build
which can cause issues with needing to restore. This is currently in a hacky state so we can discuss options.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
on thing to consider is that
/t:Build
calls the build target - and not all projects will have that target. Most managed projects will, but whatdotnet build
andmsbuild
do by default is call the default target so the most correct thing to do might be to allow specifying an optional target?you can also do
dotnet build
with--no-restore
if you want to skip the implicit restore.