Skip to content
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

Unhandled exception: System.IO.IOException: Access to the path '...\build\tools\.store\.stage\ftb2snwd.f5x' is denied. #4315

Open
2 tasks done
paulomorgado opened this issue May 24, 2024 · 1 comment

Comments

@paulomorgado
Copy link
Contributor

Prerequisites

  • I have written a descriptive issue title
  • I have searched issues to ensure it has not already been reported

Cake runner

Cake Frosting

Cake version

4.0.0

Operating system

Windows

Operating system architecture

64-Bit

CI Server

No response

What are you seeing?

This happens when a Cake Frosting program has InstallTool with dotnet.

Visual Studio hold the ...\build\tools\.store\.stage hostage:

Installing tools...
Installing tool 'Microsoft.Sbom.DotNetTool'...
Configured Tools Folder: .../build/tools
Executing: "dotnet" tool list --tool-path ".../build/tools"
Package Id      Version      Commands
-------------------------------------
There are 0 dotnet tools installed
Checking for tool: microsoft.sbom.dotnettool
Running dotnet tool with operation Install: Microsoft.Sbom.DotNetTool...
Executing: "dotnet" tool install "Microsoft.Sbom.DotNetTool" --tool-path "C:/src/services-platform/connext/connector_demo_1/build/tools" --version 2.* --verbosity diagnostic
Unhandled exception: System.IO.IOException: Access to the path '...\build\tools\.store\.stage\by43pdyi.4ao' is denied.
   at System.IO.FileSystem.MoveDirectory(String sourceFullPath, String destFullPath, Boolean _)
   at System.IO.FileSystem.MoveDirectory(String sourceFullPath, String destFullPath)
   at Microsoft.DotNet.Cli.Utils.FileAccessRetrier.RetryOnMoveAccessFailure(Action action)
   at Microsoft.DotNet.Cli.ToolPackage.ToolPackageDownloader.<>c__DisplayClass8_0.<InstallPackage>b__0()
   at Microsoft.DotNet.Cli.TransactionalAction.Run[T](Func`1 action, Action commit, Action rollback)
   at Microsoft.DotNet.Tools.Tool.Install.ToolInstallGlobalOrToolPathCommand.<>c__DisplayClass20_0.<Execute>b__1()
   at Microsoft.DotNet.Tools.Tool.Install.ToolInstallGlobalOrToolPathCommand.RunWithHandlingInstallError(Action installAction)
   at Microsoft.DotNet.Tools.Tool.Install.ToolInstallGlobalOrToolPathCommand.Execute()
   at System.CommandLine.Invocation.InvocationPipeline.Invoke(ParseResult parseResult)
   at Microsoft.DotNet.Cli.Program.ProcessArgs(String[] args, TimeSpan startupTime, ITelemetry telemetryClient)

This doesn't happen when using InstallTool with nuget.

What is expected?

This happens with this simple program:

public static class Program
{
    public static int Main(string[] args)
    {
        return new CakeHost()
            .InstallTool(new Uri("dotnet:?package=Microsoft.Sbom.DotNetTool&version=2.*"))
            .Run(args);
    }
}

Steps to Reproduce

This happens when a Cake Frosting program has InstallTool with dotnet.

Visual Studio hold the ...\build\tools\.store\.stage hostage.

This doesn't happen when using InstallTool with nuget.

Output log

Installing tools...
Installing tool 'Microsoft.Sbom.DotNetTool'...
Configured Tools Folder: .../build/tools
Executing: "dotnet" tool list --tool-path ".../build/tools"
Package Id      Version      Commands
-------------------------------------
There are 0 dotnet tools installed
Checking for tool: microsoft.sbom.dotnettool
Running dotnet tool with operation Install: Microsoft.Sbom.DotNetTool...
Executing: "dotnet" tool install "Microsoft.Sbom.DotNetTool" --tool-path "C:/src/services-platform/connext/connector_demo_1/build/tools" --version 2.* --verbosity diagnostic
Unhandled exception: System.IO.IOException: Access to the path '...\build\tools\.store\.stage\by43pdyi.4ao' is denied.
   at System.IO.FileSystem.MoveDirectory(String sourceFullPath, String destFullPath, Boolean _)
   at System.IO.FileSystem.MoveDirectory(String sourceFullPath, String destFullPath)
   at Microsoft.DotNet.Cli.Utils.FileAccessRetrier.RetryOnMoveAccessFailure(Action action)
   at Microsoft.DotNet.Cli.ToolPackage.ToolPackageDownloader.<>c__DisplayClass8_0.<InstallPackage>b__0()
   at Microsoft.DotNet.Cli.TransactionalAction.Run[T](Func`1 action, Action commit, Action rollback)
   at Microsoft.DotNet.Tools.Tool.Install.ToolInstallGlobalOrToolPathCommand.<>c__DisplayClass20_0.<Execute>b__1()
   at Microsoft.DotNet.Tools.Tool.Install.ToolInstallGlobalOrToolPathCommand.RunWithHandlingInstallError(Action installAction)
   at Microsoft.DotNet.Tools.Tool.Install.ToolInstallGlobalOrToolPathCommand.Execute()
   at System.CommandLine.Invocation.InvocationPipeline.Invoke(ParseResult parseResult)
   at Microsoft.DotNet.Cli.Program.ProcessArgs(String[] args, TimeSpan startupTime, ITelemetry telemetryClient)
@paulomorgado
Copy link
Contributor Author

The immediate workaround is to add this to the csproj:

  <PropertyGroup Condition="'$(DesignTimeBuild)' == 'true'">
    <DefineConstants>$(DefineConstants);DESIGN_TIME_BUILD</DefineConstants>
  </PropertyGroup>

And this to the program:

public static class Program
{
    public static int Main(string[] args)
    {
        return new CakeHost()
#if !DESIGN_TIME_BUILD
            .InstallTool(new Uri("dotnet:?package=Microsoft.Sbom.DotNetTool&version=2.*"))
#endif
            .Run(args);
    }
}

Does not prevent it.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant