Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

CLI: Should use the cached template if the template source specified. #19644

Merged
merged 1 commit into from
Apr 29, 2024
Merged
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 @@ -160,11 +160,10 @@ public async Task<TemplateFile> GetAsync(

var nugetVersion = version;


var localCacheFile = Path.Combine(CliPaths.TemplateCache, name.Replace("/", ".") + ".zip");

#if DEBUG
if (File.Exists(localCacheFile))
if (File.Exists(localCacheFile) && templateSource.IsNullOrWhiteSpace())
{
return new TemplateFile(File.ReadAllBytes(localCacheFile), version, latestVersion, nugetVersion);
}
Expand All @@ -176,6 +175,16 @@ public async Task<TemplateFile> GetAsync(
return new TemplateFile(File.ReadAllBytes(localCacheFile), version, latestVersion, nugetVersion);
}

if (!skipCache && !templateSource.IsNullOrWhiteSpace() && type == SourceCodeTypes.Template)
{
var templateFilePath = templateSource.EndsWith(".zip")
? templateSource
: Path.Combine(templateSource, name.Replace("/", ".").EnsureEndsWith('-') + version + ".zip");

Logger.LogInformation("Using cached template: " + name + ", version: " + version + " from template source: " + templateFilePath);
return new TemplateFile(File.ReadAllBytes(templateFilePath), version, latestVersion, nugetVersion);
}

Logger.LogInformation("Downloading " + type + ": " + name + ", version: " + version);

var fileContent = await DownloadSourceCodeContentAsync(
Expand Down
Loading