Adding a try/catch around Path.GetTempFileName() to improve UX
This commit is contained in:
parent
fdedfe93b1
commit
b29ee4d41a
2 changed files with 12 additions and 2 deletions
|
@ -162,4 +162,7 @@
|
|||
<data name="CmdPackageDirectory" xml:space="preserve">
|
||||
<value>PACKAGE_DIRECTORY</value>
|
||||
</data>
|
||||
<data name="CmdDGFileIOException" xml:space="preserve">
|
||||
<value>Unable to get a temp path for a dependency graph file for project '{0}'. Cannot add package reference.</value>
|
||||
</data>
|
||||
</root>
|
|
@ -67,8 +67,15 @@ namespace Microsoft.DotNet.Tools.Add.PackageReference
|
|||
if (!_appliedCommand.HasOption("no-restore"))
|
||||
{
|
||||
// Create a Dependency Graph file for the project
|
||||
tempDgFilePath = Path.GetTempFileName();
|
||||
GetProjectDependencyGraph(projectFilePath, tempDgFilePath);
|
||||
try
|
||||
{
|
||||
tempDgFilePath = Path.GetTempFileName();
|
||||
GetProjectDependencyGraph(projectFilePath, tempDgFilePath);
|
||||
}
|
||||
catch (IOException ioex)
|
||||
{
|
||||
throw new GracefulException(string.Format(LocalizableStrings.CmdDGFileIOException, projectFilePath));
|
||||
}
|
||||
}
|
||||
|
||||
var result = NuGetCommand.Run(
|
||||
|
|
Loading…
Reference in a new issue