SAFE-BookStore icon indicating copy to clipboard operation
SAFE-BookStore copied to clipboard

Clean build fails due to dotnetcore in use

Open daz10000 opened this issue 8 years ago • 3 comments

A clean build of a fresh pull of safe-bookstore fails when it tries to reinstall the dotnetskd

I did a fresh pull of the repo and a ./build.sh and at some point the process tried to reinstall the dotnetsdk (this seems a little aggressive for a build script BTW). As I am using dotnet for other projects right now on the machine this failed.

Repro steps

  1. Clone the repo (win10)

  2. Use dotnet to run a different program

  3. Perform ./build.sh

Expected behavior

I would expect the build to succeed or if an SDK upgrade is absolutely necessary and impossible, to provide a clean error message on exit,

Actual behavior

Starting Target: InstallDotNetCore (==> Clean)
dotnet --info
C:\Users\daz\AppData\Local\dotnetcore\dotnet.exe --info
Deleting contents of C:\Users\daz\AppData\Local\dotnetcore
Running build failed.
Error:
System.UnauthorizedAccessException: Access to the path 'C:\Users\daz\AppData\Local\dotnetcore\dotnet.exe' is denied.
   at System.IO.__Error.WinIOError(Int32 errorCode, String maybeFullPath)
   at System.IO.FileInfo.Delete()
   at [email protected](String file) in D:\code\fake\src\app\FakeLib\FileHelper.fs:line 270
   at Microsoft.FSharp.Collections.SeqModule.Iterate[T](FSharpFunc`2 action, IEnumerable`1 source)
   at Fake.FileHelper.CleanDir(String path) in D:\code\fake\src\app\FakeLib\FileHelper.fs:line 267
   at Fake.DotNetCli.InstallDotNetSDK(String sdkVersion) in D:\code\fake\src\app\FakeLib\DotNetCLIHelper.fs:line 516
   at [email protected](Unit _arg2) in C:\extproj\SAFE-BookStore2\build.fsx:line 112
   at Fake.TargetHelper.runSingleTarget(TargetTemplate`1 target) in D:\code\fake\src\app\FakeLib\TargetHelper.fs:line 626

Known workarounds

I presume closing all my running dotnetcore binaries and restarting the build will work

Related information

  • Win 10
  • master
  • .NET Command Line Tools (2.1.2)

Product Information: Version: 2.1.2 Commit SHA-1 hash: 5695315371

Runtime Environment: OS Name: Windows OS Version: 10.0.16299 OS Platform: Windows RID: win10-x64 Base Path: C:\Program Files\dotnet\sdk\2.1.2\

Microsoft .NET Core Shared Framework Host

Version : 2.0.3 Build : a9190d4a75f4a982ae4b4fa8d1a24526566c69df output.txt

daz10000 avatar Jan 01 '18 19:01 daz10000

I closed my running dotnet process, restarted the build and it is upgrading to 2.1.3 successfully now, suggest catching that System.UnauthorizedAccessException exception and emitting an error about closing running dotnet processes before building again.

daz10000 avatar Jan 01 '18 19:01 daz10000

I suppose the easiest workaround is just not to (re)install dotnet on every build. i.e. ignore the target

Target "InstallDotNetCore" (fun _ ->
    dotnetExePath <- DotNetCli.InstallDotNetSDK dotnetcliVersion
)

into

Target "InstallDotNetCore" DoNothing
// or
Target "InstallDotNetCore" (fun _ -> ())

I did this before because it takes too much time to install. Shouldn't the build script check whether or not the latest dotnet is installed and then decide to download the latest version of not?

Zaid-Ajaj avatar Jan 01 '18 19:01 Zaid-Ajaj

FAKE had a bug which caused it to reinstall dotnet in every build. Upgrading FAKE to the latest version should fix this behaviour

rommsen avatar Jan 01 '18 20:01 rommsen