Esempio n. 1
0
 /// <summary>
 /// Apply standard properties in a property group.
 /// </summary>
 public static void AddNuGetProperties(
     XDocument doc,
     IEnumerable <string> packageFolders,
     string repositoryRoot,
     ProjectStyle projectStyle,
     string assetsFilePath,
     bool success)
 {
     doc.Root.AddFirst(
         new XElement(Namespace + "PropertyGroup",
                      new XAttribute("Condition", $" {ExcludeAllCondition} "),
                      GenerateProperty("RestoreSuccess", success.ToString()),
                      GenerateProperty("RestoreTool", "NuGet"),
                      GenerateProperty("ProjectAssetsFile", assetsFilePath),
                      GenerateProperty("NuGetPackageRoot", ReplacePathsWithMacros(repositoryRoot)),
                      GenerateProperty("NuGetPackageFolders", string.Join(";", packageFolders)),
                      GenerateProperty("NuGetProjectStyle", projectStyle.ToString()),
                      GenerateProperty("NuGetToolVersion", MinClientVersionUtility.GetNuGetClientVersion().ToFullString())));
 }
        public override bool Execute()
        {
            var log = new MSBuildLogger(Log);

            // Log Inputs
            BuildTasksUtility.LogInputParam(log, nameof(HasPackageReferenceItems), HasPackageReferenceItems.ToString());
            BuildTasksUtility.LogInputParam(log, nameof(MSBuildProjectDirectory), MSBuildProjectDirectory);
            BuildTasksUtility.LogInputParam(log, nameof(MSBuildProjectName), MSBuildProjectName);
            BuildTasksUtility.LogInputParam(log, nameof(ProjectJsonPath), ProjectJsonPath);
            BuildTasksUtility.LogInputParam(log, nameof(RestoreProjectStyle), RestoreProjectStyle);

            var result = BuildTasksUtility.GetProjectRestoreStyle(RestoreProjectStyle, HasPackageReferenceItems, ProjectJsonPath, MSBuildProjectDirectory, MSBuildProjectName, log);

            IsPackageReferenceCompatibleProjectStyle = result.IsPackageReferenceCompatibleProjectStyle;
            ProjectStyle = result.ProjectStyle;

            // Log Outputs
            BuildTasksUtility.LogOutputParam(log, nameof(IsPackageReferenceCompatibleProjectStyle), IsPackageReferenceCompatibleProjectStyle.ToString());
            BuildTasksUtility.LogOutputParam(log, nameof(ProjectStyle), ProjectStyle.ToString());

            return(!Log.HasLoggedErrors);
        }