Repository navigation
Move SDK file location creation to right branch - #4546
Conversation
The SDK file creation logic was placed in a sub-branch which doesn't always execute. This was reported in the runtime repository. Fixes dotnet/runtime#871
| # Creates a temporary file under the toolset dir. | ||
| # The following code block is protecting against concurrent access so that this function can | ||
| # be called in parallel. | ||
| if ($createSdkLocationFile) { |
There was a problem hiding this comment.
Would it make sense to check whether the file exists already, as an optimization?
There was a problem hiding this comment.
In case where the sdk entry is updated in global.json and the file already exists we would still need to re-create the file as the path could have changed from repo-local to global. Also this doesn't slow the execution measurably so I think overwriting the file always is necessary to guarantee that the path is correct.
There was a problem hiding this comment.
Also the global installation could have changed, so we need to make sure that we always call into the IntializeDotNetCli function when we want to use the SDK. When doing that we should always update the file in case paths have changed.
There was a problem hiding this comment.
In case where the sdk entry is updated in global.json
If you update global.json or any similar global settings, your best bet is to clean everything and do a fresh build. The build scripts are not robust against that in many different ways.
There was a problem hiding this comment.
A .\build.cmd/sh -restore was always enough in such cases at least in corefx, core-setup and other arcadified reopsitories and should be enough in the runtime repo now.
There was a problem hiding this comment.
Are you sure? I do not think that -Force overwrites when the file exists. You should see error like this:
PS D:\repro> Rename-Item -Force -Path .\a.txt b.txt
Rename-Item : Cannot create a file when that file already exists.
There was a problem hiding this comment.
I was under the impression that force would overwrite an existing file but you are right. Instead I should probably use Move-Item -Path ... -Destination ... -Force.
There was a problem hiding this comment.
Is Move-Item -Force guaranteed to be atomic so that the parallel invocation of the scripts still work reliably?
There was a problem hiding this comment.
Just researched a bit and it seems file metadata only changes are atomic but what I'm trying to accomplish here doesn't seem to be possible with Powershell. I tend towards reverting to my old solution of just writing into the destination file directly and fall into the catch if this code path is ever hit concurrently. Does that sound fine?
There was a problem hiding this comment.
just writing into the destination file directly
This would not be reliable with concurrent use that you have said is important.
fall into the catch if this code path is ever hit concurrently
You can hit situations where one invocation sees partially written file, while the other one is overwriting it.
jkotas
left a comment
There was a problem hiding this comment.
The current delta should fix the problem that folks are reporting. The other issues being discussed can be resolved separately.
The SDK file creation logic was placed in a sub-branch which doesn't
always execute. This was reported in the runtime repository.
Fixes dotnet/runtime#871