SAFE-Stack / SAFE-BookStore

Working sample of a SAFE-Stack project with hot reloading
https://safebookstore.azurewebsites.net/
The Unlicense
492 stars 147 forks source link

Clean build fails due to dotnetcore in use #265

Closed daz10000 closed 8 months ago

daz10000 commented 6 years ago

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 Fake.FileHelper.CleanDir@267-1.Invoke(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 FSI_0005.Build.clo@111-4.Invoke(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

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 commented 6 years ago

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.

Zaid-Ajaj commented 6 years ago

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?

rommsen commented 6 years ago

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