Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -169,4 +169,7 @@
<value>Unrecognized directive '{0}'.</value>
<comment>{0} is the directive name like 'package' or 'sdk'.</comment>
</data>
</root>
<data name="EmptyTempPath" xml:space="preserve">
<value>Unable to determine a temporary directory path. Consider configuring the TEMP environment variable on Windows or local app data folder on Unix.</value>
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Path.GetTempPath on Windows never returns an empty string. If GetTempPathW or GetTempPath2W returns a zero length, it throws instead. So this advice on "configuring the TEMP environment variable on Windows" will not be seen on Windows.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Might be worth having a unit test with different OSs so that we check this situation.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Path.GetTempPath on Windows never returns an empty string.

So this advice on "configuring the TEMP environment variable on Windows" will not be seen on Windows.

Having a message that is potentially never applicable seems fine to me. I don't think it is guaranteed that Path.GetTempPath will never return an empty string in the future. The purpose of this change is to defend against bad values that would cause silent bugs down the road.

Might be worth having a unit test with different OSs so that we check this situation.

I'm not sure how can I create a unit test for this. Such test would probably need to reconfigure the OS so the empty temp path is returned.

</data>
</root>

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

5 changes: 5 additions & 0 deletions src/Cli/dotnet/Commands/Run/VirtualProjectBuildingCommand.cs
Original file line number Diff line number Diff line change
Expand Up @@ -1132,6 +1132,11 @@ public static string GetTempSubdirectory()
? Path.GetTempPath()
: Environment.GetFolderPath(Environment.SpecialFolder.LocalApplicationData);

if (string.IsNullOrEmpty(directory))
{
throw new InvalidOperationException(FileBasedProgramsResources.EmptyTempPath);
}

return Path.Join(directory, "dotnet", "runfile");
}

Expand Down
Loading