dotnet / sign

Code Signing CLI tool supporting Authenticode, NuGet, VSIX, and ClickOnce
MIT License
447 stars 84 forks source link

Feature Request: It would be useful to be able to specify the root temporary directory. #648

Open CZEMacLeod opened 8 months ago

CZEMacLeod commented 8 months ago

When running in a container, it might be the case that there is a mounted path which is faster than the overlay filesystem for handling throwaway files. When copying/overwriting an original file (or when the --output option is used that target folder), if the source and destination is on the same volume, it wouldn't have to do any actual data copying - especially if CoW were employed.

I think the existing DirectoryService could be augmented to take some options where the base temp directory would default to Path.GetTempPath() if it wasn't set to something else. https://github.com/dotnet/sign/blob/f4efed9e8fb3296f29497b90feb6548e506f2078/src/Sign.Core/FileSystem/DirectoryService.cs#L25

It might be possible just now to override the environment variables used when running the command to override where it thinks Temp is, but I feel it should be built into the CLI, rather than an external workaround.

I would suggest -tmp or --temp-directory as the command line option name.

Version: 0.9.1-beta.23530.1+f4efed9e8fb3296f29497b90feb6548e506f2078

dtivel commented 7 months ago

@CZEMacLeod, thanks for the feedback.

As a workaround, I think you can override the %TEMP% environment variable just before running Sign CLI. The override only needs to be on the process, not user- or system-wide.