Description
In a standalone C# script, Directory.GetCurrentDirectory() resolves to a temporary directory unless any #:package directive is added, which changes the behavior to resolve to the actual cwd. Please forgive me if this behavior is intended.
Reproduction Steps
- Run the following script with
dotnet run app.cs both with and without the #:package directive:
using System;
using System.IO;
#:package Empty@1.0.0
var cwd = Directory.GetCurrentDirectory();
Console.WriteLine(cwd);
- Observe that the script with the
#:package directive present will print the cwd, while the script without the #:package directive will print the path of a random temp folder.
Expected behavior
Directory.GetCurrentDirectory() should consistently resolve the actual cwd and the behavior should not be dependent on the presence or absence #:package directives.
Actual behavior
Directory.GetCurrentDirectory() resolves to a random temporary directory if no #:package directive is used and resolves to a the actual cwd if any #:package is used.
Regression?
No response
Known Workarounds
Known workaround is to always use a dummy package directive such as #:package Empty@1.0.0 (if no actual package directives are already being used) to ensure consistent behavior and correctly resolve the cwd.
Configuration
- Microsoft.WindowsDesktop.App 10.0.1
- Windows 11
- x64
Other information
No response
Description
In a standalone C# script,
Directory.GetCurrentDirectory()resolves to a temporary directory unless any#:packagedirective is added, which changes the behavior to resolve to the actual cwd. Please forgive me if this behavior is intended.Reproduction Steps
dotnet run app.csboth with and without the#:packagedirective:#:packagedirective present will print the cwd, while the script without the#:packagedirective will print the path of a random temp folder.Expected behavior
Directory.GetCurrentDirectory()should consistently resolve the actual cwd and the behavior should not be dependent on the presence or absence#:packagedirectives.Actual behavior
Directory.GetCurrentDirectory()resolves to a random temporary directory if no#:packagedirective is used and resolves to a the actual cwd if any#:packageis used.Regression?
No response
Known Workarounds
Known workaround is to always use a dummy package directive such as
#:package Empty@1.0.0(if no actual package directives are already being used) to ensure consistent behavior and correctly resolve the cwd.Configuration
Other information
No response