From 1e5d205f82c7f5bb1b2e5ce60c680491552cfa23 Mon Sep 17 00:00:00 2001 From: Jon Sequeira Date: Sun, 7 Apr 2024 16:43:34 -0700 Subject: [PATCH] package creation tweaks, NewtonSoft.Json version bumps (#3512) --- .../SampleExtensions.Tests.csproj | 2 +- .../Build/Package.cs | 25 +++++++------------ 2 files changed, 10 insertions(+), 17 deletions(-) diff --git a/samples/extensions/SampleExtensions.Tests/SampleExtensions.Tests.csproj b/samples/extensions/SampleExtensions.Tests/SampleExtensions.Tests.csproj index c23a2e4c08..1195225dab 100644 --- a/samples/extensions/SampleExtensions.Tests/SampleExtensions.Tests.csproj +++ b/samples/extensions/SampleExtensions.Tests/SampleExtensions.Tests.csproj @@ -14,7 +14,7 @@ - + all diff --git a/src/Microsoft.DotNet.Interactive.CSharpProject/Build/Package.cs b/src/Microsoft.DotNet.Interactive.CSharpProject/Build/Package.cs index fbd20834a9..e7b42a927f 100644 --- a/src/Microsoft.DotNet.Interactive.CSharpProject/Build/Package.cs +++ b/src/Microsoft.DotNet.Interactive.CSharpProject/Build/Package.cs @@ -108,15 +108,7 @@ public Package( public string Name { get; } - private Task EnsureCreatedAsync() - { - if (!EnableBuild) - { - return Task.FromResult(false); - } - - return _lazyCreation.ValueAsync(); - } + private Task EnsureCreatedAsync() => _lazyCreation.ValueAsync(); private bool TryLoadWorkspaceFromCache() { @@ -425,6 +417,11 @@ await File.WriteAllTextAsync( public async Task CreatePackage(IPackageInitializer initializer) { + if (!EnableBuild) + { + throw new InvalidOperationException($"Full build is disabled for package {this}"); + } + using var operation = Log.OnEnterAndConfirmOnExit(); if (!Directory.Exists) @@ -436,12 +433,8 @@ public async Task CreatePackage(IPackageInitializer initializer) using (await FileLock.TryCreateAsync(Directory)) { - if (!Directory.GetFiles("*", SearchOption.AllDirectories).Where(f => !FileLock.IsLockFile(f)).Any()) - { - operation.Info("Initializing package using {_initializer} in {directory}", initializer, - Directory); - await initializer.InitializeAsync(Directory); - } + operation.Info("Initializing package using {_initializer} in {directory}", initializer, Directory); + await initializer.InitializeAsync(Directory); } operation.Succeed(); @@ -454,7 +447,7 @@ public static async Task GetOrCreateConsolePackageAsync(bool enableBuil var packageBuilder = new PackageBuilder("console"); packageBuilder.UseTemplate("console"); packageBuilder.UseLanguageVersion("latest"); - packageBuilder.AddPackageReference("Newtonsoft.Json", "13.0.1"); + packageBuilder.AddPackageReference("Newtonsoft.Json", "13.0.3"); packageBuilder.EnableBuild = enableBuild; var package = packageBuilder.GetPackage(); return package;