Skip to content

Commit

Permalink
package creation tweaks, NewtonSoft.Json version bumps (#3512)
Browse files Browse the repository at this point in the history
  • Loading branch information
jonsequitur authored Apr 7, 2024
1 parent 0e8a80b commit 1e5d205
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 17 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
<PackageReference Include="microsoft.dotnet.interactive.csharp" Version="1.0.0-beta.23562.1" />
<PackageReference Include="microsoft.dotnet.interactive.fsharp" Version="1.0.0-beta.23562.1" />
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="16.10.0" />
<PackageReference Include="Newtonsoft.Json" Version="13.0.2" />
<PackageReference Include="Newtonsoft.Json" Version="13.0.3" />
<PackageReference Include="xunit" Version="2.4.2" />
<PackageReference Include="xunit.runner.visualstudio" Version="2.4.5">
<PrivateAssets>all</PrivateAssets>
Expand Down
25 changes: 9 additions & 16 deletions src/Microsoft.DotNet.Interactive.CSharpProject/Build/Package.cs
Original file line number Diff line number Diff line change
Expand Up @@ -108,15 +108,7 @@ public Package(

public string Name { get; }

private Task<bool> EnsureCreatedAsync()
{
if (!EnableBuild)
{
return Task.FromResult(false);
}

return _lazyCreation.ValueAsync();
}
private Task<bool> EnsureCreatedAsync() => _lazyCreation.ValueAsync();

private bool TryLoadWorkspaceFromCache()
{
Expand Down Expand Up @@ -425,6 +417,11 @@ await File.WriteAllTextAsync(

public async Task<bool> CreatePackage(IPackageInitializer initializer)
{
if (!EnableBuild)
{
throw new InvalidOperationException($"Full build is disabled for package {this}");
}

using var operation = Log.OnEnterAndConfirmOnExit();

if (!Directory.Exists)
Expand All @@ -436,12 +433,8 @@ public async Task<bool> 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();
Expand All @@ -454,7 +447,7 @@ public static async Task<Package> 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;
Expand Down

0 comments on commit 1e5d205

Please sign in to comment.