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

[msbuild] Pass /p:RestoreConfigFile to 'dotnet build' in addition to 'dotnet restore'. #20008

Merged
merged 2 commits into from
Feb 7, 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
18 changes: 11 additions & 7 deletions msbuild/Xamarin.MacDev.Tasks/Tasks/XamarinBuildTask.cs
Original file line number Diff line number Diff line change
Expand Up @@ -68,20 +68,23 @@ protected string ComputeValueUsingTarget (string computeValueTarget, string targ
}
}

void AddRestoreConfigFile (List<string> arguments, string dotnetPath)
{
var dotnetDir = Path.GetDirectoryName (dotnetPath);
var configFile = Path.Combine (dotnetDir, "NuGet.config");

if (File.Exists (configFile))
arguments.Add ("/p:RestoreConfigFile=" + configFile);
}

async Threading.Task ExecuteRestoreAsync (string dotnetPath, string projectPath, string targetName, Dictionary<string, string> environment)
{
var projectDirectory = Path.GetDirectoryName (projectPath);
var binlog = Path.Combine (projectDirectory, targetName + ".binlog");
var arguments = new List<string> ();

arguments.Add ("restore");

var dotnetDir = Path.GetDirectoryName (dotnetPath);
var configFile = Path.Combine (dotnetDir, "NuGet.config");

if (File.Exists (configFile)) {
arguments.Add ("/p:RestoreConfigFile=" + configFile);
}
AddRestoreConfigFile (arguments, dotnetPath);

arguments.Add ("/bl:" + binlog);
arguments.Add (projectPath);
Expand All @@ -105,6 +108,7 @@ async Threading.Task<string> ExecuteBuildAsync (string dotnetPath, string projec
var arguments = new List<string> ();

arguments.Add ("build");
AddRestoreConfigFile (arguments, dotnetPath);
arguments.Add ("/p:OutputFilePath=" + outputFile);
arguments.Add ("/p:RuntimeIdentifier=" + RuntimeIdentifier);
arguments.Add ($"/t:{targetName}");
Expand Down
Loading