Fix compiling C# scripts that use nuget package to properly resolve it on 1st build
This commit is contained in:
@@ -284,9 +284,17 @@ namespace Flax.Build
|
||||
if (buildData.TargetOptions.NugetPackageReferences.Any())
|
||||
{
|
||||
var nugetPath = Utilities.GetNugetPackagesPath();
|
||||
var restoreOnce = true;
|
||||
foreach (var reference in buildOptions.NugetPackageReferences)
|
||||
{
|
||||
var path = reference.GetLibPath(nugetPath);
|
||||
if (!File.Exists(path) && restoreOnce)
|
||||
{
|
||||
// Package binaries folder is missing so restore packages (incl. dependency packages)
|
||||
RestoreNugetPackages(graph, buildOptions.Target, buildOptions);
|
||||
restoreOnce = false;
|
||||
path = reference.GetLibPath(nugetPath);
|
||||
}
|
||||
args.Add(string.Format("/reference:\"{0}\"", path));
|
||||
}
|
||||
}
|
||||
|
||||
@@ -139,7 +139,9 @@ namespace Flax.Build.NativeCpp
|
||||
{
|
||||
if (libFolder == null)
|
||||
libFolder = GetLibFolder(nugetPath);
|
||||
var dlls = Directory.GetFiles(libFolder, "*.dll", SearchOption.TopDirectoryOnly);
|
||||
if (libFolder == string.Empty)
|
||||
return string.Empty;
|
||||
var dlls = Directory.Exists(libFolder) ? Directory.GetFiles(libFolder, "*.dll", SearchOption.TopDirectoryOnly) : [];
|
||||
if (dlls.Length == 0)
|
||||
{
|
||||
Log.Error($"Missing NuGet package \"{Name}, {Version}, {Framework}\" binaries (folder: {libFolder})");
|
||||
|
||||
Reference in New Issue
Block a user