Skip to content
This repository was archived by the owner on Apr 27, 2026. It is now read-only.
Merged
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 @@ -115,6 +115,7 @@ private bool TryLoadWorkspaceFromCache()
if (Directory.Exists)
{
var cacheFile = FindCacheFile(Directory);

if (cacheFile is not null)
{
LoadRoslynWorkspaceFromCache(cacheFile).Wait();
Expand Down Expand Up @@ -367,6 +368,11 @@ public async Task BuildAsync()

var cacheFile = FindCacheFile(Directory);

if (cacheFile is not {Exists: true})
{
throw new FileNotFoundException($"Cache file *.{BuildCacheFileUtilities.CacheFilenameSuffix} not found in {Directory}.");
}

await cacheFile.WaitForFileAvailableAsync();
await LoadRoslynWorkspaceFromCache(cacheFile);

Expand Down Expand Up @@ -453,5 +459,5 @@ public static async Task<Package> GetOrCreateConsolePackageAsync(bool enableBuil
return package;
}

internal static FileInfo FindCacheFile(DirectoryInfo directoryInfo) => directoryInfo.GetFiles("*" + BuildCacheFileUtilities.cacheFilenameSuffix).FirstOrDefault();
internal static FileInfo FindCacheFile(DirectoryInfo directoryInfo) => directoryInfo.GetFiles("*" + BuildCacheFileUtilities.CacheFilenameSuffix).FirstOrDefault();
}
Original file line number Diff line number Diff line change
Expand Up @@ -45,11 +45,11 @@ public virtual async Task InitializeAsync(DirectoryInfo directory)
{
var dotnet = new Dotnet(directory);

await dotnet.New("globaljson");
await dotnet.New("globaljson", "--force");

var result = await dotnet
.New(Template,
args: $"--name \"{ProjectName}\" --language \"{Language}\" --output \"{directory.FullName}\"");
args: $"--name \"{ProjectName}\" --language \"{Language}\" --output \"{directory.FullName}\" --force");
result.ThrowOnFailure($"Error initializing in {directory.FullName}");

if (afterCreate is not null)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ namespace Microsoft.DotNet.Interactive.CSharpProject.RoslynWorkspaceUtilities;

internal static class BuildCacheFileUtilities
{
internal static string cacheFilenameSuffix = ".interactive.workspaceData.cache";
internal static string CacheFilenameSuffix = ".interactive.workspaceData.cache";
internal static string DirectoryBuildTargetFilename = "Directory.Build.Targets";

internal static string DirectoryBuildTargetsContent =
Expand Down Expand Up @@ -128,6 +128,7 @@ internal static async Task BuildAndCreateCacheFileAsync(string csprojFilePath)
File.Delete(tempDirectoryBuildTarget);

var cacheFile = Package.FindCacheFile(directoryInfo);

if (cacheFile is not { Exists: true })
{
throw new FileNotFoundException($"Cache file not found after build completion in directory: {directoryInfo.FullName}");
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ internal static BuildDataResults ResultsFromCacheFileUsingProjectFilePath(string
throw new ArgumentException($"project file does not exist : {csprojFilePath}");
}

var cacheFilePath = csprojFilePath + cacheFilenameSuffix;
var cacheFilePath = csprojFilePath + CacheFilenameSuffix;

return GetResultsFromCacheFile(cacheFilePath);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ public CommandLineResult(

public void ThrowOnFailure(string message = null)
{
if (ExitCode != 0)
if (ExitCode is not 0)
{
throw new CommandLineInvocationException(
this,
Expand Down