Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/mono/NuGet.BuildTasks.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJason Malinowski <jason.malinowski@microsoft.com>2015-12-22 03:40:03 +0300
committerJason Malinowski <jason.malinowski@microsoft.com>2016-02-08 22:20:51 +0300
commit082835fc981f1b4ec5cf9e4c661e70228342674f (patch)
treeed61fd51a9a37f10ac0b57bc4b9a7f4430a9771d
parente9e390edfbf7b054f40b2b190700b9a39e202ff1 (diff)
Add a new task parameter which captures referenced projects
We need this so we can figure out where those projects are and some metadata about them, notably where their outputs are going to.
-rw-r--r--src/Microsoft.NuGet.Build.Tasks/ResolveNuGetPackageAssets.cs38
-rw-r--r--src/Microsoft.NuGet.Build.Tasks/Strings.Designer.cs9
-rw-r--r--src/Microsoft.NuGet.Build.Tasks/Strings.resx3
3 files changed, 48 insertions, 2 deletions
diff --git a/src/Microsoft.NuGet.Build.Tasks/ResolveNuGetPackageAssets.cs b/src/Microsoft.NuGet.Build.Tasks/ResolveNuGetPackageAssets.cs
index a833c35..02934de 100644
--- a/src/Microsoft.NuGet.Build.Tasks/ResolveNuGetPackageAssets.cs
+++ b/src/Microsoft.NuGet.Build.Tasks/ResolveNuGetPackageAssets.cs
@@ -40,6 +40,8 @@ namespace Microsoft.NuGet.Build.Tasks
private readonly List<ITaskItem> _contentItems = new List<ITaskItem>();
private readonly List<ITaskItem> _fileWrites = new List<ITaskItem>();
+ private readonly Dictionary<string, string> _projectReferencesToOutputBasePaths = new Dictionary<string, string>(StringComparer.OrdinalIgnoreCase);
+
#region UnitTestSupport
private readonly DirectoryExists _directoryExists = new DirectoryExists(Directory.Exists);
private readonly FileExists _fileExists = new FileExists(File.Exists);
@@ -134,6 +136,15 @@ namespace Microsoft.NuGet.Build.Tasks
}
/// <summary>
+ /// A list of project references that are creating packages as listed in the lock file. The OutputPath metadata should
+ /// set on each of these items, which is used by the task to construct full output paths to assets.
+ /// </summary>
+ public ITaskItem[] ProjectReferencesCreatingPackages
+ {
+ get; set;
+ }
+
+ /// <summary>
/// The base output directory where the temporary, preprocessed files should be written to.
/// </summary>
public string ContentPreprocessorOutputDirectory
@@ -217,7 +228,8 @@ namespace Microsoft.NuGet.Build.Tasks
{
lockFile = JObject.Load(new JsonTextReader(streamReader));
}
-
+
+ PopulateProjectReferenceMaps();
GetReferences(lockFile);
GetCopyLocalItems(lockFile);
GetAnalyzers(lockFile);
@@ -225,6 +237,23 @@ namespace Microsoft.NuGet.Build.Tasks
ProduceContentAssets(lockFile);
}
+ private void PopulateProjectReferenceMaps()
+ {
+ foreach (var projectReference in ProjectReferencesCreatingPackages ?? new ITaskItem[] { })
+ {
+ var fullPath = GetAbsolutePathFromProjectRelativePath(projectReference.ItemSpec);
+ if (_projectReferencesToOutputBasePaths.ContainsKey(fullPath))
+ {
+ Log.LogWarningFromResources(nameof(Strings.DuplicateProjectReference), fullPath, nameof(ProjectReferencesCreatingPackages));
+ }
+ else
+ {
+ var outputPath = projectReference.GetMetadata("OutputBasePath");
+ _projectReferencesToOutputBasePaths.Add(fullPath, outputPath);
+ }
+ }
+ }
+
private void GetReferences(JObject lockFile)
{
var target = GetTargetOrAttemptFallback(lockFile, needsRuntimeIdentifier: false);
@@ -831,7 +860,12 @@ namespace Microsoft.NuGet.Build.Tasks
yield return new NuGetPackageObject(id, version, fullPackagePath, (JObject)package.Value, libraryObject);
}
}
-
+
+ private string GetAbsolutePathFromProjectRelativePath(string path)
+ {
+ return Path.GetFullPath(Path.Combine(Path.GetDirectoryName(Path.GetFullPath(ProjectLockFile)), path));
+ }
+
/// <summary>
/// Parse the imageRuntimeVersion from COR header
/// </summary>
diff --git a/src/Microsoft.NuGet.Build.Tasks/Strings.Designer.cs b/src/Microsoft.NuGet.Build.Tasks/Strings.Designer.cs
index 6da8bc2..37b74ea 100644
--- a/src/Microsoft.NuGet.Build.Tasks/Strings.Designer.cs
+++ b/src/Microsoft.NuGet.Build.Tasks/Strings.Designer.cs
@@ -70,6 +70,15 @@ namespace Microsoft.NuGet.Build.Tasks {
}
/// <summary>
+ /// Looks up a localized string similar to The project &apos;{0}&apos; was referenced more than once in the {1} property. Ignoring all but the first..
+ /// </summary>
+ internal static string DuplicateProjectReference {
+ get {
+ return ResourceManager.GetString("DuplicateProjectReference", resourceCulture);
+ }
+ }
+
+ /// <summary>
/// Looks up a localized string similar to Lock file {0} couldn&apos;t be found. Run a NuGet package restore to generate this file..
/// </summary>
internal static string LockFileNotFound {
diff --git a/src/Microsoft.NuGet.Build.Tasks/Strings.resx b/src/Microsoft.NuGet.Build.Tasks/Strings.resx
index 7acdc67..4c03393 100644
--- a/src/Microsoft.NuGet.Build.Tasks/Strings.resx
+++ b/src/Microsoft.NuGet.Build.Tasks/Strings.resx
@@ -120,6 +120,9 @@
<data name="DuplicatePreprocessorToken" xml:space="preserve">
<value>The preprocessor token '{0}' has been given more than one value. Choosing '{1}' as the value.</value>
</data>
+ <data name="DuplicateProjectReference" xml:space="preserve">
+ <value>The project '{0}' was referenced more than once in the {1} property. Ignoring all but the first.</value>
+ </data>
<data name="LockFileNotFound" xml:space="preserve">
<value>Lock file {0} couldn't be found. Run a NuGet package restore to generate this file.</value>
</data>