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())
|
if (buildData.TargetOptions.NugetPackageReferences.Any())
|
||||||
{
|
{
|
||||||
var nugetPath = Utilities.GetNugetPackagesPath();
|
var nugetPath = Utilities.GetNugetPackagesPath();
|
||||||
|
var restoreOnce = true;
|
||||||
foreach (var reference in buildOptions.NugetPackageReferences)
|
foreach (var reference in buildOptions.NugetPackageReferences)
|
||||||
{
|
{
|
||||||
var path = reference.GetLibPath(nugetPath);
|
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));
|
args.Add(string.Format("/reference:\"{0}\"", path));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -139,7 +139,9 @@ namespace Flax.Build.NativeCpp
|
|||||||
{
|
{
|
||||||
if (libFolder == null)
|
if (libFolder == null)
|
||||||
libFolder = GetLibFolder(nugetPath);
|
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)
|
if (dlls.Length == 0)
|
||||||
{
|
{
|
||||||
Log.Error($"Missing NuGet package \"{Name}, {Version}, {Framework}\" binaries (folder: {libFolder})");
|
Log.Error($"Missing NuGet package \"{Name}, {Version}, {Framework}\" binaries (folder: {libFolder})");
|
||||||
|
|||||||
Reference in New Issue
Block a user