diff -Nru nuget-2.8.5+md59+dhx1/Build/Build.proj nuget-2.8.7+md510+dhx1/Build/Build.proj
--- nuget-2.8.5+md59+dhx1/Build/Build.proj 2015-06-11 08:15:06.000000000 +0000
+++ nuget-2.8.7+md510+dhx1/Build/Build.proj 2015-09-02 14:21:52.000000000 +0000
@@ -1,4 +1,4 @@
-
+
@@ -53,8 +53,8 @@
build servers and those built locally. -->
2
8
- 5
-
+ 7
+
2010
@@ -255,11 +255,11 @@
-
+
-
+
diff -Nru nuget-2.8.5+md59+dhx1/Common/CommonAssemblyInfo.cs nuget-2.8.7+md510+dhx1/Common/CommonAssemblyInfo.cs
--- nuget-2.8.5+md59+dhx1/Common/CommonAssemblyInfo.cs 2015-06-11 08:15:06.000000000 +0000
+++ nuget-2.8.7+md510+dhx1/Common/CommonAssemblyInfo.cs 2015-09-02 14:21:52.000000000 +0000
@@ -14,8 +14,8 @@
// Build\Build.proj.
// When built locally, the NuGet release version is the values specified in this file.
#if !FIXED_ASSEMBLY_VERSION
-[assembly: AssemblyVersion("2.8.5.0")]
-[assembly: AssemblyInformationalVersion("2.8.5")]
+[assembly: AssemblyVersion("2.8.7.0")]
+[assembly: AssemblyInformationalVersion("2.8.7")]
#endif
[assembly: NeutralResourcesLanguage("en-US")]
diff -Nru nuget-2.8.5+md59+dhx1/debian/changelog nuget-2.8.7+md510+dhx1/debian/changelog
--- nuget-2.8.5+md59+dhx1/debian/changelog 2015-06-29 10:11:25.000000000 +0000
+++ nuget-2.8.7+md510+dhx1/debian/changelog 2015-12-14 12:05:19.000000000 +0000
@@ -1,3 +1,12 @@
+nuget (2.8.7+md510+dhx1-1) unstable; urgency=medium
+
+ * [c16beaa] Add a config file for buildd usage to NuGet install
+ * [e556fa2] Imported Upstream version 2.8.7+md510+dhx1
+ * [02d3b2c] Refreshed d/p/fix_xdt_hintpath
+ * [0eb8994] Use TargetFrameworkVersion 4.5 - FTBFS without this
+
+ -- Jo Shields Mon, 14 Dec 2015 12:05:11 +0000
+
nuget (2.8.5+md59+dhx1-1) unstable; urgency=medium
* [8b67d0e] Imported Upstream version 2.8.5+md59+dhx1
diff -Nru nuget-2.8.5+md59+dhx1/debian/NuGet.buildd.Config nuget-2.8.7+md510+dhx1/debian/NuGet.buildd.Config
--- nuget-2.8.5+md59+dhx1/debian/NuGet.buildd.Config 1970-01-01 00:00:00.000000000 +0000
+++ nuget-2.8.7+md510+dhx1/debian/NuGet.buildd.Config 2015-12-14 11:52:41.000000000 +0000
@@ -0,0 +1,7 @@
+
+
+
+
+
+
+
\ No newline at end of file
diff -Nru nuget-2.8.5+md59+dhx1/debian/nuget.install nuget-2.8.7+md510+dhx1/debian/nuget.install
--- nuget-2.8.5+md59+dhx1/debian/nuget.install 2015-06-29 10:05:06.000000000 +0000
+++ nuget-2.8.7+md510+dhx1/debian/nuget.install 2015-12-14 11:53:31.000000000 +0000
@@ -1 +1,2 @@
src/CommandLine/bin/Release/NuGet.exe* /usr/lib/nuget/
+debian/NuGet.buildd.Config /usr/lib/nuget/
diff -Nru nuget-2.8.5+md59+dhx1/debian/patches/fix_xdt_hintpath nuget-2.8.7+md510+dhx1/debian/patches/fix_xdt_hintpath
--- nuget-2.8.5+md59+dhx1/debian/patches/fix_xdt_hintpath 2015-06-29 10:05:06.000000000 +0000
+++ nuget-2.8.7+md510+dhx1/debian/patches/fix_xdt_hintpath 2015-12-14 11:57:58.000000000 +0000
@@ -1,7 +1,7 @@
-Index: xamarin-pkg-nuget/src/CommandLine/CommandLine.csproj
+Index: nuget/src/CommandLine/CommandLine.csproj
===================================================================
---- xamarin-pkg-nuget.orig/src/CommandLine/CommandLine.csproj 2015-01-15 19:30:44.346864746 +0000
-+++ xamarin-pkg-nuget/src/CommandLine/CommandLine.csproj 2015-02-26 11:10:38.114087193 +0000
+--- nuget.orig/src/CommandLine/CommandLine.csproj
++++ nuget/src/CommandLine/CommandLine.csproj
@@ -32,7 +32,7 @@
@@ -11,11 +11,11 @@
-Index: xamarin-pkg-nuget/src/Core/Core.csproj
+Index: nuget/src/Core/Core.csproj
===================================================================
---- xamarin-pkg-nuget.orig/src/Core/Core.csproj 2015-02-26 11:01:59.642076980 +0000
-+++ xamarin-pkg-nuget/src/Core/Core.csproj 2015-02-26 11:10:26.654086967 +0000
-@@ -220,7 +220,7 @@
+--- nuget.orig/src/Core/Core.csproj
++++ nuget/src/Core/Core.csproj
+@@ -222,7 +222,7 @@
@@ -24,10 +24,3 @@
-@@ -321,4 +321,4 @@
-
-
- -->
--
-\ No newline at end of file
-+
diff -Nru nuget-2.8.5+md59+dhx1/debian/patches/series nuget-2.8.7+md510+dhx1/debian/patches/series
--- nuget-2.8.5+md59+dhx1/debian/patches/series 2015-06-29 10:05:06.000000000 +0000
+++ nuget-2.8.7+md510+dhx1/debian/patches/series 2015-12-14 12:00:34.000000000 +0000
@@ -1 +1,2 @@
+use_default_framework_version
fix_xdt_hintpath
diff -Nru nuget-2.8.5+md59+dhx1/debian/patches/use_default_framework_version nuget-2.8.7+md510+dhx1/debian/patches/use_default_framework_version
--- nuget-2.8.5+md59+dhx1/debian/patches/use_default_framework_version 1970-01-01 00:00:00.000000000 +0000
+++ nuget-2.8.7+md510+dhx1/debian/patches/use_default_framework_version 2015-12-14 12:05:08.000000000 +0000
@@ -0,0 +1,72 @@
+Index: nuget/src/Core/Core.csproj
+===================================================================
+--- nuget.orig/src/Core/Core.csproj
++++ nuget/src/Core/Core.csproj
+@@ -9,7 +9,7 @@
+ NuGet.Core
+ ..\..\NuGet.ruleset
+ true
+- v4.0
++ v4.5
+
+ AnyCPU
+
+@@ -323,4 +323,4 @@
+
+
+ -->
+-
++
+Index: nuget/xdt/Microsoft.Web.XmlTransform.Test/Microsoft.Web.XmlTransform.Test.csproj
+===================================================================
+--- nuget.orig/xdt/Microsoft.Web.XmlTransform.Test/Microsoft.Web.XmlTransform.Test.csproj
++++ nuget/xdt/Microsoft.Web.XmlTransform.Test/Microsoft.Web.XmlTransform.Test.csproj
+@@ -20,7 +20,7 @@
+
+
+ Properties
+- v4.0
++ v4.5
+
+
+ true
+@@ -100,4 +100,4 @@
+
+
+
+-
+\ No newline at end of file
++
+Index: nuget/xdt/XmlTransform/Microsoft.Web.XmlTransform.csproj
+===================================================================
+--- nuget.orig/xdt/XmlTransform/Microsoft.Web.XmlTransform.csproj
++++ nuget/xdt/XmlTransform/Microsoft.Web.XmlTransform.csproj
+@@ -15,7 +15,7 @@
+
+
+ Properties
+- v4.0
++ v4.5
+
+
+ true
+@@ -102,4 +102,4 @@
+
+
+
+-
+\ No newline at end of file
++
+Index: nuget/Build/NuGet.Settings.targets
+===================================================================
+--- nuget.orig/Build/NuGet.Settings.targets
++++ nuget/Build/NuGet.Settings.targets
+@@ -53,7 +53,7 @@
+
+
+
+- v4.0
++ v4.5
+ Microsoft.VisualStudio.ComponentModelHost, Version=10.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a
+ Microsoft.VisualStudio.ExtensionManager, Version=10.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a, processorArchitecture=MSIL
+ Microsoft.VisualStudio.ExtensionsExplorer, Version=10.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a, processorArchitecture=MSIL
diff -Nru nuget-2.8.5+md59+dhx1/src/CommandLine/CommandLine.csproj nuget-2.8.7+md510+dhx1/src/CommandLine/CommandLine.csproj
--- nuget-2.8.5+md59+dhx1/src/CommandLine/CommandLine.csproj 2015-06-11 08:15:06.000000000 +0000
+++ nuget-2.8.7+md510+dhx1/src/CommandLine/CommandLine.csproj 2015-09-02 14:21:52.000000000 +0000
@@ -173,8 +173,8 @@
$(OutputPath)Signed\$(ILMergeOutputFile)
$(ProgramFiles)\Reference Assemblies\Microsoft\Framework\.NETFramework\v4.0
$(MSBuildProgramFiles32)\Reference Assemblies\Microsoft\Framework\.NETFramework\v4.0
- /targetplatform:"v4, $(FrameworkPath)" /internalize:"$(ILMergeInternalizeIgnoreFile)" /target:exe /out:"Merged\$(ILMergeOutputFile)" /log:"Merged\ilmerge.msbuild.log" /ndebug /allowDup NuGet.exe NuGet.Core.dll Microsoft.Web.XmlTransform.dll
- /targetplatform:"v4, $(FrameworkPath)" /internalize:"$(ILMergeInternalizeIgnoreFile)" /target:exe /out:"Signed\$(ILMergeOutputFile)" /log:"Signed\ilmerge.msbuild.log" /ndebug /allowDup /keyfile:"$(AssemblyOriginatorKeyFile)" /delaysign NuGet.exe NuGet.Core.dll Microsoft.Web.XmlTransform.dll
+ /targetplatform:"v4, $(FrameworkPath)" /internalize:"$(ILMergeInternalizeIgnoreFile)" /target:exe /out:"Merged\$(ILMergeOutputFile)" /log:"Merged\ilmerge.msbuild.log" /allowDup NuGet.exe NuGet.Core.dll Microsoft.Web.XmlTransform.dll
+ /targetplatform:"v4, $(FrameworkPath)" /internalize:"$(ILMergeInternalizeIgnoreFile)" /target:exe /out:"Signed\$(ILMergeOutputFile)" /log:"Signed\ilmerge.msbuild.log" /allowDup /keyfile:"$(AssemblyOriginatorKeyFile)" /delaysign NuGet.exe NuGet.Core.dll Microsoft.Web.XmlTransform.dll
diff -Nru nuget-2.8.5+md59+dhx1/src/CommandLine/Commands/DownloadCommandBase.cs nuget-2.8.7+md510+dhx1/src/CommandLine/Commands/DownloadCommandBase.cs
--- nuget-2.8.5+md59+dhx1/src/CommandLine/Commands/DownloadCommandBase.cs 2015-06-11 08:15:06.000000000 +0000
+++ nuget-2.8.7+md510+dhx1/src/CommandLine/Commands/DownloadCommandBase.cs 2015-09-02 14:21:52.000000000 +0000
@@ -31,7 +31,7 @@
[Option(typeof(NuGetCommand), "CommandPackageSaveMode")]
public string PackageSaveMode { get; set; }
-
+
protected void CalculateEffectivePackageSaveMode()
{
string packageSaveModeValue = PackageSaveMode;
@@ -84,7 +84,7 @@
}
else
{
- return new PriorityPackageRepository(CacheRepository, repository);
+ return new AggregateRepository(new[] { CacheRepository, repository });
}
}
@@ -98,7 +98,7 @@
localRepository.PackageSaveMode = EffectivePackageSaveMode;
}
- var packageManager = new PackageManager(repository, pathResolver, packagesFolderFileSystem, localRepository)
+ var packageManager = new CommandLineInstallPackageManager(repository, pathResolver, packagesFolderFileSystem, localRepository)
{
Logger = Console,
CheckDowngrade = checkDowngrade
@@ -106,5 +106,26 @@
return packageManager;
}
+
+ private class CommandLineInstallPackageManager : PackageManager
+ {
+ public CommandLineInstallPackageManager(
+ IPackageRepository sourceRepository,
+ IPackagePathResolver pathResolver,
+ IFileSystem packagesFolderFileSystem,
+ IPackageRepository localRepository)
+ : base(sourceRepository, pathResolver, packagesFolderFileSystem, localRepository)
+ {
+ SkipPackageTargetCheck = true;
+ }
+
+ protected override void OnExpandFiles(PackageOperationEventArgs e)
+ {
+ e.Package.ExtractContents(e.FileSystem, e.InstallPath);
+ LocalRepository.AddPackage(e.Package);
+
+ base.ExpandSatellitePackageFiles(e.Package);
+ }
+ }
}
}
diff -Nru nuget-2.8.5+md59+dhx1/src/CommandLine/Common/ProjectHelper.cs nuget-2.8.7+md510+dhx1/src/CommandLine/Common/ProjectHelper.cs
--- nuget-2.8.5+md59+dhx1/src/CommandLine/Common/ProjectHelper.cs 2015-06-11 08:15:06.000000000 +0000
+++ nuget-2.8.7+md510+dhx1/src/CommandLine/Common/ProjectHelper.cs 2015-09-02 14:21:52.000000000 +0000
@@ -13,7 +13,8 @@
".fsproj",
".btproj",
".vcxproj",
- ".jsproj"
+ ".jsproj",
+ ".wixproj"
};
public static HashSet SupportedProjectExtensions
diff -Nru nuget-2.8.5+md59+dhx1/src/Core/Configuration/ISettings.cs nuget-2.8.7+md510+dhx1/src/Core/Configuration/ISettings.cs
--- nuget-2.8.5+md59+dhx1/src/Core/Configuration/ISettings.cs 2015-06-11 08:15:06.000000000 +0000
+++ nuget-2.8.7+md510+dhx1/src/Core/Configuration/ISettings.cs 2015-09-02 14:21:52.000000000 +0000
@@ -50,8 +50,22 @@
IList GetNestedValues(string section, string subsection);
void SetValue(string section, string key, string value);
- [SuppressMessage("Microsoft.Design", "CA1006:DoNotNestGenericTypesInMemberSignatures", Justification = "This is the best fit for this internal class")]
- void SetValues(string section, IList> values);
+
+ ///
+ /// Sets the values under the specified .
+ ///
+ /// The name of the section.
+ /// The values to set.
+ void SetValues(string section, IList values);
+
+ ///
+ /// Updates the across multiple instances in the hierarchy.
+ /// Values are updated in the with the nearest priority.
+ ///
+ /// The name of the section.
+ /// The values to set.
+ void UpdateSections(string section, IList values);
+
[SuppressMessage("Microsoft.Design", "CA1006:DoNotNestGenericTypesInMemberSignatures", Justification = "This is the best fit for this internal class")]
void SetNestedValues(string section, string key, IList> values);
diff -Nru nuget-2.8.5+md59+dhx1/src/Core/Configuration/NullSettings.cs nuget-2.8.7+md510+dhx1/src/Core/Configuration/NullSettings.cs
--- nuget-2.8.5+md59+dhx1/src/Core/Configuration/NullSettings.cs 2015-06-11 08:15:06.000000000 +0000
+++ nuget-2.8.7+md510+dhx1/src/Core/Configuration/NullSettings.cs 2015-09-02 14:21:52.000000000 +0000
@@ -34,11 +34,16 @@
throw new InvalidOperationException(String.Format(CultureInfo.CurrentCulture, NuGetResources.InvalidNullSettingsOperation, "SetValue"));
}
- public void SetValues(string section, IList> values)
+ public void SetValues(string section, IList values)
{
throw new InvalidOperationException(String.Format(CultureInfo.CurrentCulture, NuGetResources.InvalidNullSettingsOperation, "SetValues"));
}
+ public void UpdateSections(string section, IList values)
+ {
+ throw new InvalidOperationException(String.Format(CultureInfo.CurrentCulture, NuGetResources.InvalidNullSettingsOperation, "UpdateSections"));
+ }
+
public void SetNestedValues(string section, string key, IList> values)
{
throw new InvalidOperationException(String.Format(CultureInfo.CurrentCulture, NuGetResources.InvalidNullSettingsOperation, "SetNestedValues"));
diff -Nru nuget-2.8.5+md59+dhx1/src/Core/Configuration/Settings.cs nuget-2.8.7+md510+dhx1/src/Core/Configuration/Settings.cs
--- nuget-2.8.5+md59+dhx1/src/Core/Configuration/Settings.cs 2015-06-11 08:15:06.000000000 +0000
+++ nuget-2.8.7+md510+dhx1/src/Core/Configuration/Settings.cs 2015-09-02 14:21:52.000000000 +0000
@@ -17,7 +17,8 @@
private readonly string _fileName;
// next config file to read if any
private Settings _next;
-
+ // The priority of this setting file
+ private int _priority;
private readonly bool _isMachineWideSettings;
public Settings(IFileSystem fileSystem)
@@ -123,10 +124,13 @@
return NullSettings.Instance;
}
+ validSettingFiles[0]._priority = validSettingFiles.Count;
+
// if multiple setting files were loaded, chain them in a linked list
for (int i = 1; i < validSettingFiles.Count; ++i)
{
validSettingFiles[i]._next = validSettingFiles[i - 1];
+ validSettingFiles[i]._priority = validSettingFiles[i - 1]._priority - 1;
}
// return the linked list head. Typicall, it's either the config file in %ProgramData%\NuGet\Config,
@@ -153,7 +157,7 @@
{
var defaultSettingsFilePath = Path.Combine(appDataPath, "NuGet", Constants.SettingsFileName);
appDataSettings = ReadSettings(
- fileSystem ?? new PhysicalFileSystem(Directory.GetCurrentDirectory()),
+ fileSystem ?? new PhysicalFileSystem(Directory.GetCurrentDirectory()),
defaultSettingsFilePath);
}
}
@@ -199,7 +203,7 @@
string combinedPath = Path.Combine(paths);
while (true)
- {
+ {
string directory = Path.Combine(basePath, combinedPath);
// load setting files in directory
@@ -316,23 +320,22 @@
var settingValues = new List();
var curr = this;
- int priority = 0;
+
while (curr != null)
{
- curr.PopulateValues(section, settingValues, isPath, priority);
+ curr.PopulateValues(section, settingValues, isPath);
curr = curr._next;
- ++priority;
}
-
+
return settingValues.AsReadOnly();
}
- private void PopulateValues(string section, List current, bool isPath, int priority)
+ private void PopulateValues(string section, List current, bool isPath)
{
var sectionElement = GetSection(_config.Root, section);
if (sectionElement != null)
{
- ReadSection(sectionElement, current, isPath, priority);
+ ReadSection(sectionElement, current, isPath);
}
}
@@ -350,17 +353,17 @@
var values = new List();
var curr = this;
- int priority = 0;
+
while (curr != null)
{
- curr.PopulateNestedValues(section, subsection, values, priority);
+ curr.PopulateNestedValues(section, subsection, values);
curr = curr._next;
}
return values;
}
- private void PopulateNestedValues(string section, string subsection, List current, int priority)
+ private void PopulateNestedValues(string section, string subsection, List current)
{
var sectionElement = GetSection(_config.Root, section);
if (sectionElement == null)
@@ -372,7 +375,7 @@
{
return;
}
- ReadSection(subsectionElement, current, isPath: false, priority: priority);
+ ReadSection(subsectionElement, current, isPath: false);
}
public void SetValue(string section, string key, string value)
@@ -394,11 +397,11 @@
throw new ArgumentException(CommonResources.Argument_Cannot_Be_Null_Or_Empty, "section");
}
var sectionElement = GetOrCreateSection(_config.Root, section);
- SetValueInternal(sectionElement, key, value);
+ SetValueInternal(sectionElement, key, value, attributes: null);
Save();
}
- public void SetValues(string section, IList> values)
+ public void SetValues(string section, IList values)
{
// machine wide settings cannot be changed.
if (IsMachineWideSettings)
@@ -422,13 +425,90 @@
}
var sectionElement = GetOrCreateSection(_config.Root, section);
- foreach (var kvp in values)
+ foreach (var value in values)
{
- SetValueInternal(sectionElement, kvp.Key, kvp.Value);
+ SetValueInternal(sectionElement, value.Key, value.Value, value.AdditionalData);
}
Save();
}
+ public void UpdateSections(string section, IList values)
+ {
+ // machine wide settings cannot be changed.
+ if (IsMachineWideSettings)
+ {
+ if (_next == null)
+ {
+ throw new InvalidOperationException(NuGetResources.Error_NoWritableConfig);
+ }
+
+ _next.UpdateSections(section, values);
+ return;
+ }
+
+ if (string.IsNullOrEmpty(section))
+ {
+ throw new ArgumentException(CommonResources.Argument_Cannot_Be_Null_Or_Empty, "section");
+ }
+
+ if (values == null)
+ {
+ throw new ArgumentNullException("values");
+ }
+
+ var sectionElement = GetSection(_config.Root, section);
+ if (sectionElement != null)
+ {
+ sectionElement.RemoveIndented();
+ }
+
+ var valuesToWrite = _next == null ? values : values.Where(v => v.Priority < _next._priority);
+
+ if (valuesToWrite.Any())
+ {
+ sectionElement = GetOrCreateSection(_config.Root, section);
+ }
+
+ foreach (var value in valuesToWrite)
+ {
+ var element = new XElement("add");
+ SetElementValues(element, value.Key, value.Value, value.AdditionalData);
+ sectionElement.AddIndented(element);
+ }
+
+ Save();
+
+ if (_next != null)
+ {
+ _next.UpdateSections(section, values.Where(v => v.Priority >= _next._priority).ToList());
+ }
+ }
+
+ private static void SetElementValues(XElement element, string key, string value, IDictionary attributes)
+ {
+ foreach (var existingAttribute in element.Attributes())
+ {
+ if (!string.Equals(existingAttribute.Name.LocalName, "key", StringComparison.OrdinalIgnoreCase) &&
+ !string.Equals(existingAttribute.Name.LocalName, "value", StringComparison.OrdinalIgnoreCase) &&
+ !attributes.ContainsKey(existingAttribute.Name.LocalName))
+ {
+ // Remove previously existing attributes that are no longer present.
+ existingAttribute.Remove();
+ }
+ }
+
+ element.SetAttributeValue("key", key);
+ element.SetAttributeValue("value", value);
+
+ if (attributes != null)
+ {
+ foreach (var attribute in attributes)
+ {
+ element.SetAttributeValue(attribute.Key, attribute.Value);
+ }
+ }
+ }
+
public void SetNestedValues(string section, string key, IList> values)
{
// machine wide settings cannot be changed.
@@ -457,12 +537,13 @@
foreach (var kvp in values)
{
- SetValueInternal(element, kvp.Key, kvp.Value);
+ SetValueInternal(element, kvp.Key, kvp.Value, attributes: null);
}
Save();
}
- private void SetValueInternal(XElement sectionElement, string key, string value)
+
+ private void SetValueInternal(XElement sectionElement, string key, string value, IDictionary attributes)
{
if (String.IsNullOrEmpty(key))
{
@@ -474,16 +555,17 @@
}
var element = FindElementByKey(sectionElement, key, null);
+
if (element != null)
{
- element.SetAttributeValue("value", value);
+ SetElementValues(element, key, value, attributes);
Save();
}
else
{
- sectionElement.AddIndented(new XElement("add",
- new XAttribute("key", key),
- new XAttribute("value", value)));
+ element = new XElement("add");
+ SetElementValues(element, key, value, attributes);
+ sectionElement.AddIndented(element);
}
}
@@ -537,7 +619,7 @@
return _next.DeleteSection(section);
}
-
+
if (String.IsNullOrEmpty(section))
{
throw new ArgumentException(CommonResources.Argument_Cannot_Be_Null_Or_Empty, "section");
@@ -557,8 +639,7 @@
private void ReadSection(
XContainer sectionElement,
ICollection values,
- bool isPath,
- int priority)
+ bool isPath)
{
var elements = sectionElement.Elements();
@@ -567,8 +648,7 @@
string elementName = element.Name.LocalName;
if (elementName.Equals("add", StringComparison.OrdinalIgnoreCase))
{
- var v = ReadValue(element, isPath);
- values.Add(new SettingValue(v.Key, v.Value, _isMachineWideSettings, priority));
+ values.Add(ReadSettingsValue(element, isPath));
}
else if (elementName.Equals("clear", StringComparison.OrdinalIgnoreCase))
{
@@ -585,7 +665,7 @@
// When isPath is true, then the setting value is checked to see if it can be interpreted
// as relative path. If it can, the returned value will be the full path of the relative path.
// If it cannot be interpreted as relative path, the value is returned as-is.
- private KeyValuePair ReadValue(XElement element, bool isPath)
+ private SettingValue ReadSettingsValue(XElement element, bool isPath)
{
var keyAttribute = element.Attribute("key");
var valueAttribute = element.Attribute("value");
@@ -603,7 +683,18 @@
value = _fileSystem.GetFullPath(Path.Combine(configDirectory, value));
}
- return new KeyValuePair(keyAttribute.Value, value);
+ var settingValue = new SettingValue(keyAttribute.Value, value, IsMachineWideSettings, _priority);
+ foreach (var attribute in element.Attributes())
+ {
+ // Add all attributes other than ConfigurationContants.KeyAttribute and ConfigurationContants.ValueAttribute to AdditionalValues
+ if (!string.Equals(attribute.Name.LocalName, "key", StringComparison.Ordinal) &&
+ !string.Equals(attribute.Name.LocalName, "value", StringComparison.Ordinal))
+ {
+ settingValue.AdditionalData[attribute.Name.LocalName] = attribute.Value;
+ }
+ }
+
+ return settingValue;
}
private static XElement GetSection(XElement parentElement, string section)
@@ -642,7 +733,7 @@
}
return result;
}
-
+
///
/// Order is most significant (e.g. applied last) to least significant (applied first)
/// ex:
@@ -735,7 +826,7 @@
}
}
}
-
+
}
}
}
\ No newline at end of file
diff -Nru nuget-2.8.5+md59+dhx1/src/Core/Configuration/SettingValue.cs nuget-2.8.7+md510+dhx1/src/Core/Configuration/SettingValue.cs
--- nuget-2.8.5+md59+dhx1/src/Core/Configuration/SettingValue.cs 2015-06-11 08:15:06.000000000 +0000
+++ nuget-2.8.7+md510+dhx1/src/Core/Configuration/SettingValue.cs 2015-09-02 14:21:52.000000000 +0000
@@ -6,6 +6,9 @@
namespace NuGet
{
+ ///
+ /// Represents a single setting value in a settings file
+ ///
public class SettingValue
{
public SettingValue(string key, string value, bool isMachineWide, int priority = 0)
@@ -14,30 +17,52 @@
Value = value;
IsMachineWide = isMachineWide;
Priority = priority;
+ AdditionalData = new Dictionary(StringComparer.OrdinalIgnoreCase);
}
+ ///
+ /// Represents the key of the setting
+ ///
public string Key { get; private set; }
- public string Value { get; private set; }
+ ///
+ /// Represents the value of the setting
+ ///
+ public string Value { get; set; }
+
+ ///
+ /// IsMachineWide tells if the setting is machine-wide or not
+ ///
+ public bool IsMachineWide { get; set; }
- public bool IsMachineWide { get; private set; }
+ ///
+ /// The priority of this setting in the nuget.config hierarchy. Bigger number means higher priority
+ ///
+ public int Priority { get; set; }
///
- /// Gets or sets the priority of the setting value. Bigger value means higher priority.
+ /// Gets additional values with the specified setting.
///
- public int Priority { get; private set; }
+ /// When reading from an XML based settings file, this includes all attributes on the element
+ /// other than the Key and Value.
+ public IDictionary AdditionalData { get; private set; }
public override bool Equals(object obj)
{
var rhs = obj as SettingValue;
- if (rhs == null)
+
+ if (rhs != null &&
+ string.Equals(rhs.Key, Key, StringComparison.OrdinalIgnoreCase) &&
+ string.Equals(rhs.Value, Value, StringComparison.OrdinalIgnoreCase) &&
+ rhs.IsMachineWide == rhs.IsMachineWide &&
+ rhs.AdditionalData.Count == AdditionalData.Count)
{
- return false;
+ return Enumerable.SequenceEqual(
+ AdditionalData.OrderBy(data => data.Key, StringComparer.OrdinalIgnoreCase),
+ rhs.AdditionalData.OrderBy(data => data.Key, StringComparer.OrdinalIgnoreCase));
}
- return rhs.Key == Key &&
- rhs.Value == Value &&
- rhs.IsMachineWide == rhs.IsMachineWide;
+ return false;
}
public override int GetHashCode()
diff -Nru nuget-2.8.5+md59+dhx1/src/Core/Core.csproj nuget-2.8.7+md510+dhx1/src/Core/Core.csproj
--- nuget-2.8.5+md59+dhx1/src/Core/Core.csproj 2015-06-11 08:15:06.000000000 +0000
+++ nuget-2.8.7+md510+dhx1/src/Core/Core.csproj 2015-09-02 14:21:52.000000000 +0000
@@ -9,9 +9,9 @@
NuGet.Core
..\..\NuGet.ruleset
true
+ v4.0
AnyCPU
- v4.0
@@ -117,6 +117,8 @@
+
+
@@ -321,4 +323,4 @@
-->
-
\ No newline at end of file
+
diff -Nru nuget-2.8.5+md59+dhx1/src/Core/Http/ProxyCache.cs nuget-2.8.7+md510+dhx1/src/Core/Http/ProxyCache.cs
--- nuget-2.8.5+md59+dhx1/src/Core/Http/ProxyCache.cs 2015-06-11 08:14:57.000000000 +0000
+++ nuget-2.8.7+md510+dhx1/src/Core/Http/ProxyCache.cs 2015-09-02 14:21:52.000000000 +0000
@@ -4,7 +4,7 @@
namespace NuGet
{
- internal class ProxyCache : IProxyCache
+ public class ProxyCache : IProxyCache
{
private const string HostKey = "http_proxy";
private const string UserKey = "http_proxy.user";
@@ -27,12 +27,12 @@
private static readonly Lazy _instance = new Lazy(() => new ProxyCache());
public ProxyCache()
{
-
}
-#else
- // It's not likely that http proxy settings are set in machine wide settings,
+#else
+
+ // It's not likely that http proxy settings are set in machine wide settings,
// so not passing machine wide settings to Settings.LoadDefaultSettings() should be fine.
- private static readonly Lazy _instance = new Lazy(() => new ProxyCache(Settings.LoadDefaultSettings(fileSystem: null, configFileName: null, machineWideSettings: null ), new EnvironmentVariableWrapper()));
+ private static readonly Lazy _instance = new Lazy(() => new ProxyCache(Settings.LoadDefaultSettings(fileSystem: null, configFileName: null, machineWideSettings: null), new EnvironmentVariableWrapper()));
private readonly ISettings _settings;
private readonly IEnvironmentVariableReader _environment;
@@ -42,9 +42,10 @@
_settings = settings;
_environment = environment;
}
+
#endif
- internal static ProxyCache Instance
+ public static ProxyCache Instance
{
get
{
@@ -67,7 +68,7 @@
}
return configuredProxy;
}
-#endif
+#endif
if (!IsSystemProxySet(uri))
{
return null;
@@ -86,13 +87,14 @@
}
#if !BOOTSTRAPPER
+
internal WebProxy GetUserConfiguredProxy()
{
// Try reading from the settings. The values are stored as 3 config values http_proxy, http_proxy_user, http_proxy_password
var host = _settings.GetConfigValue(HostKey);
if (!String.IsNullOrEmpty(host))
{
- // The host is the minimal value we need to assume a user configured proxy.
+ // The host is the minimal value we need to assume a user configured proxy.
var webProxy = new WebProxy(host);
string userName = _settings.GetConfigValue(UserKey);
string password = _settings.GetConfigValue(PasswordKey, decrypt: true);
@@ -122,6 +124,7 @@
}
return null;
}
+
#endif
public void Add(IWebProxy proxy)
@@ -179,5 +182,4 @@
return proxy != null;
}
}
-
-}
+}
\ No newline at end of file
diff -Nru nuget-2.8.5+md59+dhx1/src/Core/PackageManager.cs nuget-2.8.7+md510+dhx1/src/Core/PackageManager.cs
--- nuget-2.8.5+md59+dhx1/src/Core/PackageManager.cs 2015-06-11 08:15:06.000000000 +0000
+++ nuget-2.8.7+md510+dhx1/src/Core/PackageManager.cs 2015-09-02 14:21:52.000000000 +0000
@@ -100,6 +100,12 @@
set;
}
+ ///
+ /// Gets or sets a value that determines if the walk operation during install
+ /// verifies the targetability (Project \ External) of the package.
+ ///
+ public bool SkipPackageTargetCheck { get; set; }
+
public void InstallPackage(string packageId)
{
InstallPackage(packageId, version: null, ignoreDependencies: false, allowPrereleaseVersions: false);
@@ -147,7 +153,8 @@
DependencyVersion)
{
DisableWalkInfo = ignoreWalkInfo,
- CheckDowngrade = CheckDowngrade
+ CheckDowngrade = CheckDowngrade,
+ SkipPackageTargetCheck = SkipPackageTargetCheck
};
Execute(package, installerWalker);
}
@@ -248,14 +255,7 @@
// Add files
FileSystem.AddFiles(files, packageDirectory);
- // If this is a Satellite Package, then copy the satellite files into the related runtime package folder too
- IPackage runtimePackage;
- if (PackageHelper.IsSatellitePackage(package, LocalRepository, targetFramework: null, runtimePackage: out runtimePackage))
- {
- var satelliteFiles = package.GetSatelliteFiles();
- var runtimePath = PathResolver.GetPackageDirectory(runtimePackage);
- FileSystem.AddFiles(satelliteFiles, runtimePath);
- }
+ ExpandSatellitePackageFiles(package);
}
finally
{
@@ -266,6 +266,18 @@
}
}
+ protected void ExpandSatellitePackageFiles(IPackage package)
+ {
+ // If this is a Satellite Package, then copy the satellite files into the related runtime package folder too
+ IPackage runtimePackage;
+ if (PackageHelper.IsSatellitePackage(package, LocalRepository, targetFramework: null, runtimePackage: out runtimePackage))
+ {
+ var satelliteFiles = package.GetSatelliteFiles();
+ var runtimePath = PathResolver.GetPackageDirectory(runtimePackage);
+ FileSystem.AddFiles(satelliteFiles, runtimePath);
+ }
+ }
+
public void UninstallPackage(string packageId)
{
UninstallPackage(packageId, version: null, forceRemove: false, removeDependencies: false);
diff -Nru nuget-2.8.5+md59+dhx1/src/Core/Packages/Constants.cs nuget-2.8.7+md510+dhx1/src/Core/Packages/Constants.cs
--- nuget-2.8.5+md59+dhx1/src/Core/Packages/Constants.cs 2015-06-11 08:14:57.000000000 +0000
+++ nuget-2.8.7+md510+dhx1/src/Core/Packages/Constants.cs 2015-09-02 14:21:52.000000000 +0000
@@ -32,6 +32,11 @@
public static readonly string ToolsDirectory = "tools";
///
+ /// Represents the ".nupkg.sha512" extension.
+ ///
+ public static readonly string HashFileExtension = PackageExtension + ".sha512";
+
+ ///
/// Represents the build directory in the package.
///
public static readonly string BuildDirectory = "build";
diff -Nru nuget-2.8.5+md59+dhx1/src/Core/Packages/DataServicePackage.cs nuget-2.8.7+md510+dhx1/src/Core/Packages/DataServicePackage.cs
--- nuget-2.8.5+md59+dhx1/src/Core/Packages/DataServicePackage.cs 2015-06-11 08:15:06.000000000 +0000
+++ nuget-2.8.7+md510+dhx1/src/Core/Packages/DataServicePackage.cs 2015-09-02 14:21:52.000000000 +0000
@@ -349,6 +349,11 @@
return Package.GetStream();
}
+ public void ExtractContents(IFileSystem fileSystem, string extractPath)
+ {
+ Package.ExtractContents(fileSystem, extractPath);
+ }
+
public override string ToString()
{
return this.GetFullName();
diff -Nru nuget-2.8.5+md59+dhx1/src/Core/Packages/IPackage.cs nuget-2.8.7+md510+dhx1/src/Core/Packages/IPackage.cs
--- nuget-2.8.5+md59+dhx1/src/Core/Packages/IPackage.cs 2015-06-11 08:15:06.000000000 +0000
+++ nuget-2.8.7+md510+dhx1/src/Core/Packages/IPackage.cs 2015-09-02 14:21:52.000000000 +0000
@@ -26,5 +26,7 @@
[SuppressMessage("Microsoft.Design", "CA1024:UsePropertiesWhereAppropriate", Justification = "This might be expensive")]
Stream GetStream();
+
+ void ExtractContents(IFileSystem fileSystem, string extractPath);
}
}
\ No newline at end of file
diff -Nru nuget-2.8.5+md59+dhx1/src/Core/Packages/LocalPackage.cs nuget-2.8.7+md510+dhx1/src/Core/Packages/LocalPackage.cs
--- nuget-2.8.5+md59+dhx1/src/Core/Packages/LocalPackage.cs 2015-06-11 08:14:57.000000000 +0000
+++ nuget-2.8.7+md510+dhx1/src/Core/Packages/LocalPackage.cs 2015-09-02 14:21:52.000000000 +0000
@@ -205,6 +205,8 @@
}
public abstract Stream GetStream();
+
+ public abstract void ExtractContents(IFileSystem fileSystem, string extractPath);
[System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Design", "CA1024:UsePropertiesWhereAppropriate", Justification = "This operation can be expensive.")]
protected abstract IEnumerable GetFilesBase();
diff -Nru nuget-2.8.5+md59+dhx1/src/Core/Packages/OptimizedZipPackage.cs nuget-2.8.7+md510+dhx1/src/Core/Packages/OptimizedZipPackage.cs
--- nuget-2.8.5+md59+dhx1/src/Core/Packages/OptimizedZipPackage.cs 2015-06-11 08:14:57.000000000 +0000
+++ nuget-2.8.7+md510+dhx1/src/Core/Packages/OptimizedZipPackage.cs 2015-09-02 14:21:52.000000000 +0000
@@ -155,6 +155,18 @@
return _fileSystem.OpenFile(_packagePath);
}
+ public override void ExtractContents(IFileSystem fileSystem, string extractPath)
+ {
+ EnsurePackageFiles();
+ foreach (var item in _files)
+ {
+ using (var stream = item.Value.GetStream())
+ {
+ fileSystem.AddFile(Path.Combine(extractPath, item.Value.TargetPath), stream);
+ }
+ }
+ }
+
protected override IEnumerable GetFilesBase()
{
EnsurePackageFiles();
@@ -192,22 +204,7 @@
{
using (Stream stream = _fileSystem.OpenFile(_packagePath))
{
- Package package = Package.Open(stream);
- PackageRelationship relationshipType = package.GetRelationshipsByType(Constants.PackageRelationshipNamespace + PackageBuilder.ManifestRelationType).SingleOrDefault();
-
- if (relationshipType == null)
- {
- throw new InvalidOperationException(NuGetResources.PackageDoesNotContainManifest);
- }
-
- PackagePart manifestPart = package.GetPart(relationshipType.TargetUri);
-
- if (manifestPart == null)
- {
- throw new InvalidOperationException(NuGetResources.PackageDoesNotContainManifest);
- }
-
- using (Stream manifestStream = manifestPart.GetStream())
+ using (Stream manifestStream = PackageHelper.GetManifestStream(stream))
{
ReadManifest(manifestStream);
}
diff -Nru nuget-2.8.5+md59+dhx1/src/Core/Packages/UnzippedPackage.cs nuget-2.8.7+md510+dhx1/src/Core/Packages/UnzippedPackage.cs
--- nuget-2.8.5+md59+dhx1/src/Core/Packages/UnzippedPackage.cs 2015-06-11 08:14:57.000000000 +0000
+++ nuget-2.8.7+md510+dhx1/src/Core/Packages/UnzippedPackage.cs 2015-09-02 14:21:52.000000000 +0000
@@ -30,7 +30,7 @@
{
private readonly IFileSystem _repositoryFileSystem;
private readonly string _packageFileName;
- private readonly string _packageName;
+ private readonly string _packagePath;
///
/// Create an uninstance of UnzippedPackage class
@@ -54,11 +54,36 @@
throw new ArgumentException(CommonResources.Argument_Cannot_Be_Null_Or_Empty, "packageName");
}
- _packageName = packageName;
_packageFileName = packageName + Constants.PackageExtension;
+ _packagePath = packageName;
_repositoryFileSystem = repositoryFileSystem;
- EnsureManifest();
+ // we look for the .nuspec file at jQuery.1.4\jQuery.1.4.nuspec
+ var manifestPath = Path.Combine(packageName, packageName + Constants.ManifestExtension);
+ EnsureManifest(manifestPath);
+ }
+
+ public UnzippedPackage(IFileSystem repositoryFileSystem, string packageId, SemanticVersion version)
+ {
+ if (repositoryFileSystem == null)
+ {
+ throw new ArgumentNullException("repositoryFileSystem");
+ }
+
+ if (String.IsNullOrEmpty(packageId))
+ {
+ throw new ArgumentException(CommonResources.Argument_Cannot_Be_Null_Or_Empty, "packageId");
+ }
+
+ if (version == null)
+ {
+ throw new ArgumentNullException("version");
+ }
+
+ _repositoryFileSystem = repositoryFileSystem;
+ _packagePath = Path.Combine(packageId, version.ToNormalizedString());
+ _packageFileName = Path.Combine(_packagePath, packageId + "." + version.ToNormalizedString() + Constants.PackageExtension);
+ EnsureManifest(Path.Combine(_packagePath, packageId + Constants.ManifestExtension));
}
public override Stream GetStream()
@@ -70,10 +95,22 @@
}
// if not exists, check under \A.1.0.0\A.1.0.0.nupkg
- string path = Path.Combine(_packageName, _packageFileName);
+ string path = Path.Combine(_packagePath, _packageFileName);
return _repositoryFileSystem.OpenFile(path);
}
+ public override void ExtractContents(IFileSystem fileSystem, string extractPath)
+ {
+ foreach (var file in GetFilesBase().Cast())
+ {
+ var targetPath = Path.Combine(extractPath, file.TargetPath);
+ using (var fileStream = file.GetStream())
+ {
+ fileSystem.AddFile(targetPath, fileStream);
+ }
+ }
+ }
+
public override IEnumerable GetSupportedFrameworks()
{
string effectivePath;
@@ -98,7 +135,7 @@
protected override IEnumerable GetAssemblyReferencesCore()
{
- string libDirectory = Path.Combine(_packageName, Constants.LibDirectory);
+ string libDirectory = Path.Combine(_packagePath, Constants.LibDirectory);
return from p in _repositoryFileSystem.GetFiles(libDirectory, "*.*", recursive: true)
let targetPath = GetPackageRelativePath(p)
@@ -112,7 +149,7 @@
private IEnumerable GetPackageFilePaths()
{
- return from p in _repositoryFileSystem.GetFiles(_packageName, "*.*", recursive: true)
+ return from p in _repositoryFileSystem.GetFiles(_packagePath, "*.*", recursive: true)
where !PackageHelper.IsManifest(p) && !PackageHelper.IsPackageFile(p)
select p;
}
@@ -121,26 +158,24 @@
{
// Package paths returned by the file system contain the package name. We need to yank this out of the package name because the paths we are interested in are
// package relative paths.
- Debug.Assert(path.StartsWith(_packageName, StringComparison.OrdinalIgnoreCase));
- return path.Substring(_packageName.Length + 1);
+ Debug.Assert(path.StartsWith(_packagePath, StringComparison.OrdinalIgnoreCase));
+ return path.Substring(_packagePath.Length + 1);
}
- private void EnsureManifest()
+ private void EnsureManifest(string manifestFilePath)
{
- // we look for the .nuspec file at jQuery.1.4\jQuery.1.4.nuspec
- string manifestFile = Path.Combine(_packageName, _packageName + Constants.ManifestExtension);
- if (!_repositoryFileSystem.FileExists(manifestFile))
+ if (!_repositoryFileSystem.FileExists(manifestFilePath))
{
throw new InvalidOperationException(
- String.Format(CultureInfo.CurrentCulture, NuGetResources.Manifest_NotFound, _repositoryFileSystem.GetFullPath(manifestFile)));
+ String.Format(CultureInfo.CurrentCulture, NuGetResources.Manifest_NotFound, _repositoryFileSystem.GetFullPath(manifestFilePath)));
}
- using (Stream manifestStream = _repositoryFileSystem.OpenFile(manifestFile))
+ using (Stream manifestStream = _repositoryFileSystem.OpenFile(manifestFilePath))
{
ReadManifest(manifestStream);
}
- Published = _repositoryFileSystem.GetLastModified(manifestFile);
+ Published = _repositoryFileSystem.GetLastModified(manifestFilePath);
}
}
}
\ No newline at end of file
diff -Nru nuget-2.8.5+md59+dhx1/src/Core/Packages/ZipPackage.cs nuget-2.8.7+md510+dhx1/src/Core/Packages/ZipPackage.cs
--- nuget-2.8.5+md59+dhx1/src/Core/Packages/ZipPackage.cs 2015-06-11 08:14:57.000000000 +0000
+++ nuget-2.8.7+md510+dhx1/src/Core/Packages/ZipPackage.cs 2015-09-02 14:21:52.000000000 +0000
@@ -31,6 +31,23 @@
{
}
+ public ZipPackage(Func packageStreamFactory, Func manifestStreamFactory)
+ {
+ if (packageStreamFactory == null)
+ {
+ throw new ArgumentNullException("packageStreamFactory");
+ }
+
+ if (manifestStreamFactory == null)
+ {
+ throw new ArgumentNullException("manifestStreamFactory");
+ }
+
+ _enableCaching = false;
+ _streamFactory = packageStreamFactory;
+ EnsureManifest(manifestStreamFactory);
+ }
+
public ZipPackage(Stream stream)
{
if (stream == null)
@@ -39,7 +56,10 @@
}
_enableCaching = false;
_streamFactory = stream.ToStreamFactory();
- EnsureManifest();
+ using (stream = _streamFactory())
+ {
+ EnsureManifest(() => GetManifestStreamFromPackage(stream));
+ }
}
private ZipPackage(string filePath, bool enableCaching)
@@ -50,7 +70,10 @@
}
_enableCaching = enableCaching;
_streamFactory = () => File.OpenRead(filePath);
- EnsureManifest();
+ using (var stream = _streamFactory())
+ {
+ EnsureManifest(() => GetManifestStreamFromPackage(stream));
+ }
}
internal ZipPackage(Func streamFactory, bool enableCaching)
@@ -61,7 +84,10 @@
}
_enableCaching = enableCaching;
_streamFactory = streamFactory;
- EnsureManifest();
+ using (var stream = _streamFactory())
+ {
+ EnsureManifest(() => GetManifestStreamFromPackage(stream));
+ }
}
public override Stream GetStream()
@@ -69,6 +95,25 @@
return _streamFactory();
}
+ public override void ExtractContents(IFileSystem fileSystem, string extractPath)
+ {
+ using (Stream stream = _streamFactory())
+ {
+ var package = Package.Open(stream);
+
+ foreach (var part in package.GetParts().Where(IsPackageFile))
+ {
+ var relativePath = UriUtility.GetPath(part.Uri);
+
+ var targetPath = Path.Combine(extractPath, relativePath);
+ using (var partStream = part.GetStream())
+ {
+ fileSystem.AddFile(targetPath, partStream);
+ }
+ }
+ }
+ }
+
public override IEnumerable GetSupportedFrameworks()
{
IEnumerable fileFrameworks;
@@ -135,31 +180,33 @@
}
}
- private void EnsureManifest()
+ private void EnsureManifest(Func manifestStreamFactory)
{
- using (Stream stream = _streamFactory())
+ using (Stream manifestStream = manifestStreamFactory())
{
- Package package = Package.Open(stream);
+ ReadManifest(manifestStream);
+ }
+ }
- PackageRelationship relationshipType = package.GetRelationshipsByType(Constants.PackageRelationshipNamespace + PackageBuilder.ManifestRelationType).SingleOrDefault();
+ private static Stream GetManifestStreamFromPackage(Stream packageStream)
+ {
+ Package package = Package.Open(packageStream);
- if (relationshipType == null)
- {
- throw new InvalidOperationException(NuGetResources.PackageDoesNotContainManifest);
- }
+ PackageRelationship relationshipType = package.GetRelationshipsByType(Constants.PackageRelationshipNamespace + PackageBuilder.ManifestRelationType).SingleOrDefault();
- PackagePart manifestPart = package.GetPart(relationshipType.TargetUri);
+ if (relationshipType == null)
+ {
+ throw new InvalidOperationException(NuGetResources.PackageDoesNotContainManifest);
+ }
- if (manifestPart == null)
- {
- throw new InvalidOperationException(NuGetResources.PackageDoesNotContainManifest);
- }
+ PackagePart manifestPart = package.GetPart(relationshipType.TargetUri);
- using (Stream manifestStream = manifestPart.GetStream())
- {
- ReadManifest(manifestStream);
- }
+ if (manifestPart == null)
+ {
+ throw new InvalidOperationException(NuGetResources.PackageDoesNotContainManifest);
}
+
+ return manifestPart.GetStream();
}
private string GetFilesCacheKey()
diff -Nru nuget-2.8.5+md59+dhx1/src/Core/PackageSource/PackageSource.cs nuget-2.8.7+md510+dhx1/src/Core/PackageSource/PackageSource.cs
--- nuget-2.8.5+md59+dhx1/src/Core/PackageSource/PackageSource.cs 2015-06-11 08:15:06.000000000 +0000
+++ nuget-2.8.7+md510+dhx1/src/Core/PackageSource/PackageSource.cs 2015-09-02 14:21:52.000000000 +0000
@@ -6,6 +6,8 @@
[DataContract]
public class PackageSource : IEquatable
{
+ public static readonly int DefaultProtocolVersion = 2;
+
private readonly int _hashCode;
[DataMember]
@@ -30,6 +32,8 @@
public bool IsPasswordClearText { get; set; }
+ public int ProtocolVersion { get; set; }
+
public PackageSource(string source) :
this(source, source, isEnabled: true)
{
@@ -61,6 +65,7 @@
Source = source;
IsEnabled = isEnabled;
IsOfficial = isOfficial;
+ ProtocolVersion = DefaultProtocolVersion;
_hashCode = Name.ToUpperInvariant().GetHashCode() * 3137 + Source.ToUpperInvariant().GetHashCode();
}
@@ -97,7 +102,14 @@
public PackageSource Clone()
{
- return new PackageSource(Source, Name, IsEnabled, IsOfficial) { UserName = UserName, Password = Password, IsPasswordClearText = IsPasswordClearText, IsMachineWide = IsMachineWide };
+ return new PackageSource(Source, Name, IsEnabled, IsOfficial)
+ {
+ UserName = UserName,
+ Password = Password,
+ IsPasswordClearText = IsPasswordClearText,
+ IsMachineWide = IsMachineWide,
+ ProtocolVersion = ProtocolVersion
+ };
}
}
}
\ No newline at end of file
diff -Nru nuget-2.8.5+md59+dhx1/src/Core/PackageSource/PackageSourceProvider.cs nuget-2.8.7+md510+dhx1/src/Core/PackageSource/PackageSourceProvider.cs
--- nuget-2.8.5+md59+dhx1/src/Core/PackageSource/PackageSourceProvider.cs 2015-06-11 08:15:06.000000000 +0000
+++ nuget-2.8.7+md510+dhx1/src/Core/PackageSource/PackageSourceProvider.cs 2015-09-02 14:21:52.000000000 +0000
@@ -1,17 +1,21 @@
using System;
using System.Collections.Generic;
+using System.Diagnostics.CodeAnalysis;
+using System.Globalization;
using System.Linq;
namespace NuGet
{
public class PackageSourceProvider : IPackageSourceProvider
{
+ private const int MaxSupportedProtocolVersion = 2;
private const string PackageSourcesSectionName = "packageSources";
private const string DisabledPackageSourcesSectionName = "disabledPackageSources";
private const string CredentialsSectionName = "packageSourceCredentials";
private const string UsernameToken = "Username";
private const string PasswordToken = "Password";
private const string ClearTextPasswordToken = "ClearTextPassword";
+ private const string ProtocolVersionAttribute = "protocolVersion";
private readonly ISettings _settingsManager;
private readonly IEnumerable _providerDefaultSources;
private readonly IDictionary _migratePackageSources;
@@ -64,89 +68,60 @@
///
public IEnumerable LoadPackageSources()
{
- var sources = new HashSet(StringComparer.OrdinalIgnoreCase);
- var settingsValue = new List();
- IList values = _settingsManager.GetValues(PackageSourcesSectionName, isPath: true);
- var machineWideSourcesCount = 0;
-
- if (!values.IsEmpty())
- {
- var machineWideSources = new List();
-
- // remove duplicate sources. Pick the one with the highest priority.
- // note that Reverse() is needed because items in 'values' is in
- // ascending priority order.
- foreach (var settingValue in values.Reverse())
- {
- if (!sources.Contains(settingValue.Key))
- {
- if (settingValue.IsMachineWide)
- {
- machineWideSources.Add(settingValue);
- }
- else
- {
- settingsValue.Add(settingValue);
- }
-
- sources.Add(settingValue.Key);
- }
- }
+ IList sourceSettingValues = _settingsManager.GetValues(PackageSourcesSectionName, isPath: true) ??
+ new SettingValue[0];
- // Reverse the the list to be backward compatible
- settingsValue.Reverse();
- machineWideSourcesCount = machineWideSources.Count;
+ // Order the list so that they are ordered in priority order
+ var settingValues = sourceSettingValues.OrderByDescending(setting => setting.Priority);
- // Add machine wide sources at the end
- settingsValue.AddRange(machineWideSources);
- }
+ // get list of disabled packages
+ var disabledSetting = _settingsManager.GetValues(DisabledPackageSourcesSectionName, isPath: false) ?? Enumerable.Empty();
- var loadedPackageSources = new List();
- if (!settingsValue.IsEmpty())
+ var disabledSources = new Dictionary(StringComparer.OrdinalIgnoreCase);
+ foreach (var setting in disabledSetting)
{
- // Create disabledSources list
- var disabledSourcesValues = _settingsManager.GetValues(DisabledPackageSourcesSectionName, isPath: false) ??
- Enumerable.Empty();
-
- // the value of this dictionary is the priority value
- var disabledSources = new Dictionary(StringComparer.CurrentCultureIgnoreCase);
- foreach (var v in disabledSourcesValues)
+ if (disabledSources.ContainsKey(setting.Key))
{
- if (!disabledSources.ContainsKey(v.Key) ||
- disabledSources[v.Key] < v.Priority)
- {
- disabledSources[v.Key] = v.Priority;
- }
+ disabledSources[setting.Key] = setting;
}
+ else
+ {
+ disabledSources.Add(setting.Key, setting);
+ }
+ }
- // Create loadedPackageSources list
- loadedPackageSources = new List();
- foreach (var p in settingsValue)
- {
- string name = p.Key;
- string src = p.Value;
- PackageSourceCredential creds = ReadCredential(name);
-
- var isEnabled = !disabledSources.ContainsKey(name) ||
- disabledSources[name] < p.Priority;
- var packageSource = new PackageSource(src, name, isEnabled)
- {
- UserName = creds != null ? creds.Username : null,
- Password = creds != null ? creds.Password : null,
- IsPasswordClearText = creds != null && creds.IsPasswordClearText,
- IsMachineWide = p.IsMachineWide
- };
-
- loadedPackageSources.Add(packageSource);
+ var packageSourceLookup = new Dictionary(StringComparer.OrdinalIgnoreCase);
+ var packageIndex = 0;
+ foreach (var setting in settingValues)
+ {
+ var name = setting.Key;
+
+ bool isEnabled = true;
+ SettingValue disabledSource;
+ if (disabledSources.TryGetValue(name, out disabledSource) &&
+ disabledSource.Priority >= setting.Priority)
+ {
+ isEnabled = false;
}
- if (_migratePackageSources != null)
+ var packageSource = ReadPackageSource(setting, isEnabled);
+ if (packageSource.ProtocolVersion <= MaxSupportedProtocolVersion)
{
- MigrateSources(loadedPackageSources);
+ packageIndex = AddOrUpdateIndexedSource(packageSourceLookup, packageIndex, packageSource);
}
}
- SetDefaultPackageSources(loadedPackageSources, machineWideSourcesCount);
+ var loadedPackageSources = packageSourceLookup.Values
+ .OrderBy(source => source.Index)
+ .Select(source => source.PackageSource)
+ .ToList();
+
+ if (_migratePackageSources != null)
+ {
+ MigrateSources(loadedPackageSources);
+ }
+
+ SetDefaultPackageSources(loadedPackageSources);
return loadedPackageSources;
}
@@ -215,7 +190,7 @@
}
}
- private void SetDefaultPackageSources(List loadedPackageSources, int machineWideSourcesCount)
+ private void SetDefaultPackageSources(List loadedPackageSources)
{
// There are 4 different cases to consider for default package sources
// Case 1. Default Package Source is already present matching both feed source and the feed name
@@ -263,7 +238,15 @@
}
}
}
- loadedPackageSources.InsertRange(loadedPackageSources.Count - machineWideSourcesCount, defaultPackageSourcesToBeAdded);
+
+ var defaultSourcesInsertIndex = loadedPackageSources.FindIndex(source => source.IsMachineWide);
+ if (defaultSourcesInsertIndex == -1)
+ {
+ defaultSourcesInsertIndex = loadedPackageSources.Count;
+ }
+
+ // Default package sources go ahead of machine wide sources
+ loadedPackageSources.InsertRange(defaultSourcesInsertIndex, defaultPackageSourcesToBeAdded);
}
private void UpdateProviderDefaultSources(List loadedSources)
@@ -278,24 +261,95 @@
}
}
+ [SuppressMessage("Microsoft.Maintainability", "CA1502", Justification = "This is ported from NuGet3 and we want to keep the implementations in sync.")]
public void SavePackageSources(IEnumerable sources)
{
// clear the old values
- _settingsManager.DeleteSection(PackageSourcesSectionName);
-
// and write the new ones
- _settingsManager.SetValues(
- PackageSourcesSectionName,
- sources.Where(p => !p.IsMachineWide)
- .Select(p => new KeyValuePair(p.Name, p.Source))
- .ToList());
+ var sourcesToWrite = sources.Where(s => !s.IsMachineWide);
- // overwrite new values for the section
- _settingsManager.DeleteSection(DisabledPackageSourcesSectionName);
+ var existingSettings = (_settingsManager.GetValues(PackageSourcesSectionName, isPath: true) ??
+ Enumerable.Empty()).Where(setting => !setting.IsMachineWide).ToList();
- _settingsManager.SetValues(
- DisabledPackageSourcesSectionName,
- sources.Where(p => !p.IsEnabled).Select(p => new KeyValuePair(p.Name, "true")).ToList());
+ var existingSettingsLookup = existingSettings.ToLookup(setting => setting.Key, StringComparer.OrdinalIgnoreCase);
+ var existingDisabledSources = _settingsManager.GetValues(DisabledPackageSourcesSectionName, isPath: false) ??
+ Enumerable.Empty();
+ var existingDisabledSourcesLookup = existingDisabledSources.ToLookup(setting => setting.Key, StringComparer.OrdinalIgnoreCase);
+
+ var sourceSettings = new List();
+ var sourcesToDisable = new List();
+
+ foreach (var source in sourcesToWrite)
+ {
+ var foundSettingWithSourcePriority = false;
+ var settingPriority = 0;
+ var existingSettingForSource = existingSettingsLookup[source.Name];
+
+ // Preserve packageSource entries from low priority settings.
+ foreach (var existingSetting in existingSettingForSource)
+ {
+ settingPriority = Math.Max(settingPriority, existingSetting.Priority);
+
+ // Write all settings other than the currently written one to the current NuGet.config.
+ if (ReadProtocolVersion(existingSetting) == source.ProtocolVersion)
+ {
+ // Update the source value of all settings with the same protocol version.
+ existingSetting.Value = source.Source;
+ foundSettingWithSourcePriority = true;
+ }
+ sourceSettings.Add(existingSetting);
+ }
+
+ if (!foundSettingWithSourcePriority)
+ {
+ // This is a new source, add it to the Setting with the lowest priority.
+ var settingValue = new SettingValue(source.Name, source.Source, isMachineWide: false);
+ if (source.ProtocolVersion != PackageSource.DefaultProtocolVersion)
+ {
+ settingValue.AdditionalData[ProtocolVersionAttribute] =
+ source.ProtocolVersion.ToString(CultureInfo.InvariantCulture);
+ }
+
+ sourceSettings.Add(settingValue);
+ }
+
+ // settingValue contains the setting with the highest priority.
+
+ var existingDisabledSettings = existingDisabledSourcesLookup[source.Name];
+ // Preserve disabledPackageSource entries from low priority settings.
+ foreach (var setting in existingDisabledSettings.Where(s => s.Priority < settingPriority))
+ {
+ sourcesToDisable.Add(setting);
+ }
+
+ if (!source.IsEnabled)
+ {
+ // Add an entry to the disabledPackageSource in the file that contains
+ sourcesToDisable.Add(new SettingValue(source.Name, "true", isMachineWide: false, priority: settingPriority));
+ }
+ }
+
+ // Re-add all settings with a higher protocol version that weren't listed. Skip any settings where the source is
+ // already being written and any setting with any source with a protocol version < 2 (the max supported version).
+ // The latter indicates a deleted source.
+ var sourcesWithHigherProtocolVersion = existingSettingsLookup
+ .Where(item =>
+ !sourcesToWrite.Any(s => string.Equals(s.Name, item.Key, StringComparison.OrdinalIgnoreCase)) &&
+ !item.Any(s => ReadProtocolVersion(s) <= MaxSupportedProtocolVersion))
+ .SelectMany(s => s);
+ sourceSettings.AddRange(sourcesWithHigherProtocolVersion);
+
+ // Add disabled machine wide sources
+ foreach (var source in sources.Where(s => s.IsMachineWide && !s.IsEnabled))
+ {
+ sourcesToDisable.Add(new SettingValue(source.Name, "true", isMachineWide: false));
+ }
+
+ // Write the updates to the nearest settings file.
+ _settingsManager.UpdateSections(PackageSourcesSectionName, sourceSettings);
+
+ // overwrite new values for the section
+ _settingsManager.UpdateSections(DisabledPackageSourcesSectionName, sourcesToDisable);
// Overwrite the section
_settingsManager.DeleteSection(CredentialsSectionName);
@@ -336,7 +390,7 @@
}
string value = _settingsManager.GetValue(
- DisabledPackageSourcesSectionName,
+ DisabledPackageSourcesSectionName,
source.Name,
isPath: false);
@@ -345,6 +399,64 @@
return String.IsNullOrEmpty(value);
}
+ private PackageSource ReadPackageSource(SettingValue setting, bool isEnabled)
+ {
+ var name = setting.Key;
+ var packageSource = new PackageSource(setting.Value, name, isEnabled)
+ {
+ IsMachineWide = setting.IsMachineWide
+ };
+
+ var credentials = ReadCredential(name);
+ if (credentials != null)
+ {
+ packageSource.UserName = credentials.Username;
+ packageSource.Password = credentials.Password;
+ packageSource.IsPasswordClearText = credentials.IsPasswordClearText;
+ }
+
+ packageSource.ProtocolVersion = ReadProtocolVersion(setting);
+
+ return packageSource;
+ }
+
+ private static int ReadProtocolVersion(SettingValue setting)
+ {
+ string protocolVersionString;
+ int protocolVersion;
+ if (setting.AdditionalData.TryGetValue(ProtocolVersionAttribute, out protocolVersionString) &&
+ int.TryParse(protocolVersionString, out protocolVersion))
+ {
+ return protocolVersion;
+ }
+
+ return PackageSource.DefaultProtocolVersion;
+ }
+
+ private static int AddOrUpdateIndexedSource(
+ Dictionary packageSourceLookup,
+ int packageIndex,
+ PackageSource packageSource)
+ {
+ IndexedPackageSource previouslyAddedSource;
+ if (!packageSourceLookup.TryGetValue(packageSource.Name, out previouslyAddedSource))
+ {
+ packageSourceLookup[packageSource.Name] = new IndexedPackageSource
+ {
+ PackageSource = packageSource,
+ Index = packageIndex++
+ };
+ }
+ else if (previouslyAddedSource.PackageSource.ProtocolVersion < packageSource.ProtocolVersion)
+ {
+ // Pick the package source with the highest supported protocol version
+ previouslyAddedSource.PackageSource = packageSource;
+ }
+
+ return packageIndex;
+ }
+
+
private class PackageSourceCredential
{
public string Username { get; private set; }
@@ -358,5 +470,12 @@
IsPasswordClearText = isPasswordClearText;
}
}
+
+ private class IndexedPackageSource
+ {
+ public int Index { get; set; }
+
+ public PackageSource PackageSource { get; set; }
+ }
}
}
\ No newline at end of file
diff -Nru nuget-2.8.5+md59+dhx1/src/Core/PackageWalker/PackageWalker.cs nuget-2.8.7+md510+dhx1/src/Core/PackageWalker/PackageWalker.cs
--- nuget-2.8.5+md59+dhx1/src/Core/PackageWalker/PackageWalker.cs 2015-06-11 08:15:06.000000000 +0000
+++ nuget-2.8.7+md510+dhx1/src/Core/PackageWalker/PackageWalker.cs 2015-09-02 14:21:52.000000000 +0000
@@ -25,6 +25,8 @@
DependencyVersion = DependencyVersion.Lowest;
}
+ public virtual bool SkipPackageTargetCheck { get; set; }
+
protected FrameworkName TargetFramework
{
get
@@ -172,19 +174,31 @@
private static void CheckPackageMinClientVersion(IPackage package)
{
// validate that the current version of NuGet satisfies the minVersion attribute specified in the .nuspec
- if (Constants.NuGetVersion < package.MinClientVersion)
+ if (Constants.NuGetVersion < GetMinClientVersion(package))
{
throw new NuGetVersionNotSatisfiedException(
String.Format(CultureInfo.CurrentCulture, NuGetResources.PackageMinVersionNotSatisfied, package.GetFullName(), package.MinClientVersion, Constants.NuGetVersion));
}
}
+ private static readonly Version AlternativeMinClientVersion281 = new Version ("2.8.50313");
+
+ private static Version GetMinClientVersion(IPackage package)
+ {
+ if (package.MinClientVersion == AlternativeMinClientVersion281)
+ {
+ return new Version (2, 8, 1, 0);
+ }
+
+ return package.MinClientVersion;
+ }
+
///
/// Resolve the package target (i.e. if the parent package was a meta package then set the parent to the current project type)
///
private void ProcessPackageTarget(IPackage package)
{
- if (IgnoreWalkInfo)
+ if (IgnoreWalkInfo || SkipPackageTargetCheck)
{
return;
}
diff -Nru nuget-2.8.5+md59+dhx1/src/Core/Repositories/AggregateRepository.cs nuget-2.8.7+md510+dhx1/src/Core/Repositories/AggregateRepository.cs
--- nuget-2.8.5+md59+dhx1/src/Core/Repositories/AggregateRepository.cs 2015-06-11 08:15:06.000000000 +0000
+++ nuget-2.8.7+md510+dhx1/src/Core/Repositories/AggregateRepository.cs 2015-09-02 14:21:52.000000000 +0000
@@ -1,4 +1,5 @@
using System;
+using System.Collections;
using System.Collections.Concurrent;
using System.Collections.Generic;
using System.Diagnostics.CodeAnalysis;
@@ -66,7 +67,8 @@
Func supportsPrereleasePackages = Wrap(r => r.SupportsPrereleasePackages, defaultValue: true);
_supportsPrereleasePackages = new Lazy(() => _repositories.All(supportsPrereleasePackages));
- IgnoreFailingRepositories = true;
+ IgnoreFailingRepositories = repositories.OfType().All(r => r.IgnoreFailingRepositories);
+ Logger = repositories.OfType().Select(r => r.Logger).FirstOrDefault(l => l != NullLogger.Instance);
}
[SuppressMessage("Microsoft.Design", "CA1031:DoNotCatchGeneralExceptionTypes", Justification = "We want to suppress any exception that we may encounter.")]
diff -Nru nuget-2.8.5+md59+dhx1/src/Core/Repositories/DataServiceContextWrapper.cs nuget-2.8.7+md510+dhx1/src/Core/Repositories/DataServiceContextWrapper.cs
--- nuget-2.8.5+md59+dhx1/src/Core/Repositories/DataServiceContextWrapper.cs 2015-06-11 08:15:06.000000000 +0000
+++ nuget-2.8.7+md510+dhx1/src/Core/Repositories/DataServiceContextWrapper.cs 2015-09-02 14:21:52.000000000 +0000
@@ -1,11 +1,12 @@
using System;
using System.Collections.Generic;
using System.Data.Services.Client;
+using System.Diagnostics;
using System.Diagnostics.CodeAnalysis;
+using System.Globalization;
using System.IO;
using System.Linq;
using System.Reflection;
-using System.Text;
using System.Xml.Linq;
namespace NuGet
@@ -28,9 +29,25 @@
{
MergeOption = MergeOption.OverwriteChanges
};
+
+ // Makes the context use our own resolve type function
+ // since we know the exact type for the given wire name.
+ // With this, the oData initialization time is cut in half.
+ _context.ResolveType = ResolveTypeFunction;
_metadataUri = _context.GetMetadataUri();
}
+ private Type ResolveTypeFunction(string wireName)
+ {
+ if (wireName.EndsWith("V2FeedPackage", StringComparison.OrdinalIgnoreCase))
+ {
+ return typeof(DataServicePackage);
+ }
+
+ Debug.Assert(false, "we should never reach here");
+ return null;
+ }
+
public Uri BaseUri
{
get
@@ -114,7 +131,6 @@
.SelectMany(o => o.Cast());
}
-
public Uri GetReadStreamUri(object entity)
{
return _context.GetReadStreamUri(entity);
@@ -225,7 +241,7 @@
private static IEnumerable ExtractSupportedProperties(XDocument schemaDocument, string packageEntityName)
{
// The name is listed in the entity set listing as
- // We need to extract the name portion to look up the entity type
+ /// Represents a NuGet v3 style expanded repository. Packages in this repository are
+ /// stored in the format {id}/{version}/{unzipped-contents}
+ ///
+ public class ExpandedPackageRepository : PackageRepositoryBase, IPackageLookup
+ {
+ private readonly IFileSystem _fileSystem;
+ private readonly IHashProvider _hashProvider;
+
+ public ExpandedPackageRepository(IFileSystem fileSystem)
+ : this(fileSystem, new CryptoHashProvider())
+ {
+ }
+
+ public ExpandedPackageRepository(
+ IFileSystem fileSystem,
+ IHashProvider hashProvider)
+ {
+ _fileSystem = fileSystem;
+ _hashProvider = hashProvider;
+ }
+
+ public override string Source
+ {
+ get { return _fileSystem.Root; }
+ }
+
+ public override bool SupportsPrereleasePackages
+ {
+ get { return true; }
+ }
+
+ public override void AddPackage(IPackage package)
+ {
+ var packagePath = GetPackageRoot(package.Id, package.Version);
+ var nupkgPath = Path.Combine(packagePath, package.Id + "." + package.Version.ToNormalizedString() + Constants.PackageExtension);
+
+ using (var stream = package.GetStream())
+ {
+ _fileSystem.AddFile(nupkgPath, stream);
+ }
+
+ var hashBytes = Encoding.UTF8.GetBytes(package.GetHash(_hashProvider));
+ var hashFilePath = Path.ChangeExtension(nupkgPath, Constants.HashFileExtension);
+ _fileSystem.AddFile(hashFilePath, hashFileStream => { hashFileStream.Write(hashBytes, 0, hashBytes.Length); });
+
+ using (var stream = package.GetStream())
+ {
+ using (var manifestStream = PackageHelper.GetManifestStream(stream))
+ {
+ var manifestPath = Path.Combine(packagePath, package.Id + Constants.ManifestExtension);
+ _fileSystem.AddFile(manifestPath, manifestStream);
+ }
+ }
+ }
+
+ public override void RemovePackage(IPackage package)
+ {
+ if (Exists(package.Id, package.Version))
+ {
+ var packagePath = GetPackageRoot(package.Id, package.Version);
+ _fileSystem.DeleteDirectorySafe(packagePath, recursive: true);
+ }
+ }
+
+ public bool Exists(string packageId, SemanticVersion version)
+ {
+ var hashFilePath = Path.ChangeExtension(GetPackagePath(packageId, version), Constants.HashFileExtension);
+ return _fileSystem.FileExists(hashFilePath);
+ }
+
+ public IPackage FindPackage(string packageId, SemanticVersion version)
+ {
+ if (!Exists(packageId, version))
+ {
+ return null;
+ }
+
+ return GetPackageInternal(packageId, version);
+ }
+
+ public IEnumerable FindPackagesById(string packageId)
+ {
+ foreach (var versionDirectory in _fileSystem.GetDirectoriesSafe(packageId))
+ {
+ var versionDirectoryName = Path.GetFileName(versionDirectory);
+ SemanticVersion version;
+ if (SemanticVersion.TryParse(versionDirectoryName, out version) &&
+ Exists(packageId, version))
+ {
+ yield return GetPackageInternal(packageId, version);
+ }
+ }
+ }
+
+ public override IQueryable GetPackages()
+ {
+ return _fileSystem.GetDirectoriesSafe(path: string.Empty)
+ .SelectMany(packageDirectory =>
+ {
+ var packageId = Path.GetFileName(packageDirectory);
+ return FindPackagesById(packageId);
+ }).AsQueryable();
+ }
+
+ private static string GetPackageRoot(string packageId, SemanticVersion version)
+ {
+ return Path.Combine(packageId, version.ToNormalizedString());
+ }
+
+ private IPackage GetPackageInternal(string packageId, SemanticVersion version)
+ {
+ var packagePath = GetPackagePath(packageId, version);
+ var manifestPath = Path.Combine(GetPackageRoot(packageId, version), packageId + Constants.ManifestExtension);
+ return new ZipPackage(() => _fileSystem.OpenFile(packagePath), () => _fileSystem.OpenFile(manifestPath));
+ }
+
+ private static string GetPackagePath(string packageId, SemanticVersion version)
+ {
+ return Path.Combine(
+ GetPackageRoot(packageId, version),
+ packageId + "." + version.ToNormalizedString() + Constants.PackageExtension);
+ }
+ }
+}
diff -Nru nuget-2.8.5+md59+dhx1/src/Core/Repositories/LazyLocalPackageRepository.cs nuget-2.8.7+md510+dhx1/src/Core/Repositories/LazyLocalPackageRepository.cs
--- nuget-2.8.5+md59+dhx1/src/Core/Repositories/LazyLocalPackageRepository.cs 1970-01-01 00:00:00.000000000 +0000
+++ nuget-2.8.7+md510+dhx1/src/Core/Repositories/LazyLocalPackageRepository.cs 2015-09-02 14:21:52.000000000 +0000
@@ -0,0 +1,106 @@
+using System;
+using System.Collections.Generic;
+using System.IO;
+using System.Linq;
+
+namespace NuGet
+{
+ ///
+ /// A physical file-system based repository that defers detecting if the directory is a v2 or a v3 style repository until
+ /// the first repository operation is performed.
+ ///
+ public class LazyLocalPackageRepository : PackageRepositoryBase, IPackageLookup
+ {
+ private readonly Lazy _repository;
+ private readonly IFileSystem _fileSystem;
+
+ public LazyLocalPackageRepository(string path)
+ : this(new PhysicalFileSystem(path))
+ {
+ }
+
+ public LazyLocalPackageRepository(IFileSystem fileSystem)
+ {
+ _fileSystem = fileSystem;
+ _repository = new Lazy(() => CreateRepository(fileSystem));
+ }
+
+ public override string Source
+ {
+ get { return _fileSystem.Root; }
+ }
+
+ public override bool SupportsPrereleasePackages
+ {
+ get { return true; }
+ }
+
+ // Internal for unit testing.
+ internal IPackageRepository Repository
+ {
+ get { return _repository.Value; }
+ }
+
+ public override IQueryable GetPackages()
+ {
+ return Repository.GetPackages();
+ }
+
+ public override void AddPackage(IPackage package)
+ {
+ Repository.AddPackage(package);
+ }
+
+ public override void RemovePackage(IPackage package)
+ {
+ Repository.RemovePackage(package);
+ }
+
+ public bool Exists(string packageId, SemanticVersion version)
+ {
+ return Repository.Exists(packageId, version);
+ }
+
+ public IPackage FindPackage(string packageId, SemanticVersion version)
+ {
+ return Repository.FindPackage(packageId, version);
+ }
+
+ public IEnumerable FindPackagesById(string packageId)
+ {
+ return Repository.FindPackagesById(packageId);
+ }
+
+ private static IPackageRepository CreateRepository(IFileSystem fileSystem)
+ {
+ if (!fileSystem.DirectoryExists(path: string.Empty) ||
+ fileSystem.GetFiles(path: string.Empty, filter: "*.nupkg").Any())
+ {
+ // If the repository does not exist or if there are .nupkg in the path, this is a v2-style repository.
+ return new LocalPackageRepository(new DefaultPackagePathResolver(fileSystem), fileSystem);
+ }
+
+ foreach (var idDirectory in fileSystem.GetDirectories(path: string.Empty))
+ {
+ if (fileSystem.GetFiles(idDirectory, "*.nupkg").Any() ||
+ fileSystem.GetFiles(idDirectory, "*.nuspec").Any())
+ {
+ // ~/Foo/Foo.1.0.0.nupkg (LocalPackageRepository with PackageSaveModes.Nupkg) or
+ // ~/Foo/Foo.1.0.0.nuspec (LocalPackageRepository with PackageSaveMode.Nuspec)
+ return new LocalPackageRepository(new DefaultPackagePathResolver(fileSystem), fileSystem);
+ }
+
+ foreach (var versionDirectoryPath in fileSystem.GetDirectories(idDirectory))
+ {
+ if (fileSystem.GetFiles(versionDirectoryPath, idDirectory + Constants.ManifestExtension).Any())
+ {
+ // If we have files in the format {packageId}/{version}/{packageId}.nuspec, assume it's an expanded package repository.
+ return new ExpandedPackageRepository(fileSystem);
+ }
+ }
+ }
+
+ return new LocalPackageRepository(new DefaultPackagePathResolver(fileSystem), fileSystem);
+ }
+ }
+}
diff -Nru nuget-2.8.5+md59+dhx1/src/Core/Repositories/LocalPackageRepository.cs nuget-2.8.7+md510+dhx1/src/Core/Repositories/LocalPackageRepository.cs
--- nuget-2.8.5+md59+dhx1/src/Core/Repositories/LocalPackageRepository.cs 2015-06-11 08:14:57.000000000 +0000
+++ nuget-2.8.7+md510+dhx1/src/Core/Repositories/LocalPackageRepository.cs 2015-09-02 14:21:52.000000000 +0000
@@ -1,3 +1,4 @@
+using NuGet.Resources;
using System;
using System.Collections.Concurrent;
using System.Collections.Generic;
@@ -5,7 +6,6 @@
using System.Globalization;
using System.IO;
using System.Linq;
-using NuGet.Resources;
namespace NuGet
{
@@ -165,12 +165,12 @@
public virtual IEnumerable GetPackageLookupPaths(string packageId, SemanticVersion version)
{
- // Files created by the path resolver. This would take into account the non-side-by-side scenario
+ // Files created by the path resolver. This would take into account the non-side-by-side scenario
// and we do not need to match this for id and version.
var packageFileName = PathResolver.GetPackageFileName(packageId, version);
var manifestFileName = Path.ChangeExtension(packageFileName, Constants.ManifestExtension);
var filesMatchingFullName = Enumerable.Concat(
- GetPackageFiles(packageFileName),
+ GetPackageFiles(packageFileName),
GetPackageFiles(manifestFileName));
if (version != null && version.Version.Revision < 1)
@@ -188,7 +188,7 @@
string partialManifestName = partialName + "*" + Constants.ManifestExtension;
partialName += "*" + Constants.PackageExtension;
- // Partial names would result is gathering package with matching major and minor but different build and revision.
+ // Partial names would result is gathering package with matching major and minor but different build and revision.
// Attempt to match the version in the path to the version we're interested in.
var partialNameMatches = GetPackageFiles(partialName).Where(path => FileNameMatchesPattern(packageId, version, path));
var partialManifestNameMatches = GetPackageFiles(partialManifestName).Where(
@@ -211,7 +211,7 @@
return GetPackage(openPackage, packagePath);
}
- // Lookup files which start with the name "." and attempt to match it with all possible version string combinations (e.g. 1.2.0, 1.2.0.0)
+ // Lookup files which start with the name "." and attempt to match it with all possible version string combinations (e.g. 1.2.0, 1.2.0.0)
// before opening the package. To avoid creating file name strings, we attempt to specifically match everything after the last path separator
// which would be the file name and extension.
return (from path in GetPackageLookupPaths(packageId, version)
@@ -229,27 +229,27 @@
// get packages through nupkg files
packages.AddRange(
GetPackages(
- openPackage,
- packageId,
+ openPackage,
+ packageId,
GetPackageFiles(packageId + "*" + Constants.PackageExtension)));
// then, get packages through nuspec files
packages.AddRange(
GetPackages(
- openPackage,
- packageId,
+ openPackage,
+ packageId,
GetPackageFiles(packageId + "*" + Constants.ManifestExtension)));
return packages;
}
- internal IEnumerable GetPackages(Func openPackage,
+ internal IEnumerable GetPackages(Func openPackage,
string packageId,
IEnumerable packagePaths)
{
foreach (var path in packagePaths)
{
IPackage package = null;
- try
+ try
{
package = GetPackage(openPackage, path);
}
@@ -257,12 +257,12 @@
{
// ignore error for unzipped packages (nuspec files).
if (string.Equals(
- Constants.ManifestExtension,
- Path.GetExtension(path),
+ Constants.ManifestExtension,
+ Path.GetExtension(path),
StringComparison.OrdinalIgnoreCase))
- {
+ {
}
- else
+ else
{
throw;
}
@@ -275,10 +275,23 @@
}
}
+ [System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Design", "CA1031:DoNotCatchGeneralExceptionTypes",
+ Justification = "We want to suppress all errors opening a package")]
internal IEnumerable GetPackages(Func openPackage)
{
- return from path in GetPackageFiles()
- select GetPackage(openPackage, path);
+ return GetPackageFiles()
+ .Select(path =>
+ {
+ try
+ {
+ return GetPackage(openPackage, path);
+ }
+ catch
+ {
+ return null;
+ }
+ })
+ .Where(p => p != null);
}
private IPackage GetPackage(Func openPackage, string path)
@@ -318,7 +331,7 @@
filter.EndsWith(Constants.ManifestExtension, StringComparison.OrdinalIgnoreCase));
// Check for package files one level deep. We use this at package install time
- // to determine the set of installed packages. Installed packages are copied to
+ // to determine the set of installed packages. Installed packages are copied to
// {id}.{version}\{packagefile}.{extension}.
foreach (var dir in FileSystem.GetDirectories(String.Empty))
{
@@ -335,7 +348,7 @@
}
}
- protected virtual IPackage OpenPackage(string path)
+ internal virtual IPackage OpenPackage(string path)
{
if (!FileSystem.FileExists(path))
{
@@ -386,7 +399,7 @@
var name = Path.GetFileNameWithoutExtension(path);
SemanticVersion parsedVersion;
- // When matching by pattern, we will always have a version token. Packages without versions would be matched early on by the version-less path resolver
+ // When matching by pattern, we will always have a version token. Packages without versions would be matched early on by the version-less path resolver
// when doing an exact match.
return name.Length > packageId.Length &&
SemanticVersion.TryParse(name.Substring(packageId.Length + 1), out parsedVersion) &&
@@ -410,6 +423,7 @@
}
public IPackage Package { get; private set; }
+
public DateTimeOffset LastModifiedTime { get; private set; }
}
}
diff -Nru nuget-2.8.5+md59+dhx1/src/Core/Repositories/PackageRepositoryFactory.cs nuget-2.8.7+md510+dhx1/src/Core/Repositories/PackageRepositoryFactory.cs
--- nuget-2.8.5+md59+dhx1/src/Core/Repositories/PackageRepositoryFactory.cs 2015-06-11 08:14:57.000000000 +0000
+++ nuget-2.8.7+md510+dhx1/src/Core/Repositories/PackageRepositoryFactory.cs 2015-09-02 14:21:52.000000000 +0000
@@ -32,7 +32,7 @@
Uri uri = new Uri(packageSource);
if (uri.IsFile)
{
- return new LocalPackageRepository(uri.LocalPath);
+ return new LazyLocalPackageRepository(uri.LocalPath);
}
var client = HttpClientFactory(uri);
diff -Nru nuget-2.8.5+md59+dhx1/src/Core/Repositories/SharedPackageRepository.cs nuget-2.8.7+md510+dhx1/src/Core/Repositories/SharedPackageRepository.cs
--- nuget-2.8.5+md59+dhx1/src/Core/Repositories/SharedPackageRepository.cs 2015-06-11 08:15:06.000000000 +0000
+++ nuget-2.8.7+md510+dhx1/src/Core/Repositories/SharedPackageRepository.cs 2015-09-02 14:21:52.000000000 +0000
@@ -1,11 +1,11 @@
-using System;
+using NuGet.Resources;
+using System;
using System.Collections.Generic;
using System.Globalization;
using System.IO;
using System.Linq;
using System.Xml;
using System.Xml.Linq;
-using NuGet.Resources;
namespace NuGet
{
@@ -68,7 +68,7 @@
{
if (version != null)
{
- // optimization: if we find the .nuspec file at "id.version"\"id.version".nuspec or
+ // optimization: if we find the .nuspec file at "id.version"\"id.version".nuspec or
// the .nupkg file at "id.version"\"id.version".nupkg, consider it exists
bool hasPackageDirectory = version.GetComparableVersionStrings()
.Select(v => packageId + "." + v)
@@ -132,7 +132,7 @@
string nupkgPath = partialPath + Constants.PackageExtension;
if (FileSystem.FileExists(nupkgPath))
{
- yield return new SharedOptimizedZipPackage(FileSystem, nupkgPath);
+ yield return new SharedOptimizedZipPackage(FileSystem, nupkgPath);
}
else if (FileSystem.FileExists(partialPath + Constants.ManifestExtension))
{
@@ -157,8 +157,8 @@
public override void RemovePackage(IPackage package)
{
- // IMPORTANT (bug #3114) Even though we delete the entire package's directory,
- // we still need to explicitly delete the .nuspec and .nupkg files in order to
+ // IMPORTANT (bug #3114) Even though we delete the entire package's directory,
+ // we still need to explicitly delete the .nuspec and .nupkg files in order to
// undo pending TFS add operations, if any.
string manifestFilePath = GetManifestFilePath(package.Id, package.Version);
if (FileSystem.FileExists(manifestFilePath))
@@ -166,7 +166,7 @@
// delete .nuspec file
FileSystem.DeleteFileSafe(manifestFilePath);
}
-
+
string packageFilePath = GetPackageFilePath(package);
if (FileSystem.FileExists(packageFilePath))
{
@@ -198,15 +198,15 @@
protected virtual IPackageRepository CreateRepository(string path)
{
string root = PathUtility.EnsureTrailingSlash(FileSystem.Root);
- string absolutePath = PathUtility.GetAbsolutePath(root, path);
+ string absolutePath = PathUtility.GetAbsolutePath(root, path);
return new PackageReferenceRepository(absolutePath, sourceRepository: this);
}
- protected override IPackage OpenPackage(string path)
+ internal override IPackage OpenPackage(string path)
{
if (!FileSystem.FileExists(path))
{
- return null;
+ return null;
}
string extension = Path.GetExtension(path);
@@ -254,7 +254,7 @@
// Only save if we changed the document
bool requiresSave = false;
- // Paths have to be relative to the this repository
+ // Paths have to be relative to the this repository
var paths = new HashSet();
foreach (var e in GetRepositoryElements(document).ToList())
{
@@ -419,8 +419,8 @@
private bool IsSolutionLevel(IPackage package)
{
- // A package is solution level if
- // - it doesn't have project content &
+ // A package is solution level if
+ // - it doesn't have project content &
// - it doesn't have dependency on non solution-level package &
// - it is not referenced by any project.
if (package.HasProjectContent())
diff -Nru nuget-2.8.5+md59+dhx1/src/Core/SemanticVersion.cs nuget-2.8.7+md510+dhx1/src/Core/SemanticVersion.cs
--- nuget-2.8.5+md59+dhx1/src/Core/SemanticVersion.cs 2015-06-11 08:14:57.000000000 +0000
+++ nuget-2.8.7+md510+dhx1/src/Core/SemanticVersion.cs 2015-09-02 14:21:52.000000000 +0000
@@ -1,6 +1,7 @@
using System;
using System.ComponentModel;
using System.Globalization;
+using System.Text;
using System.Text.RegularExpressions;
using NuGet.Resources;
@@ -18,6 +19,7 @@
private static readonly Regex _semanticVersionRegex = new Regex(@"^(?\d+(\s*\.\s*\d+){0,3})(?-[a-z][0-9a-z-]*)?$", _flags);
private static readonly Regex _strictSemanticVersionRegex = new Regex(@"^(?\d+(\.\d+){2})(?-[a-z][0-9a-z-]*)?$", _flags);
private readonly string _originalString;
+ private string _normalizedVersionString;
public SemanticVersion(string version)
: this(Parse(version))
@@ -120,7 +122,7 @@
{
// if 'a' has less than 4 elements, we pad the '0' at the end
// to make it 4.
- var b = new string[4] { "0", "0", "0", "0"};
+ var b = new string[4] { "0", "0", "0", "0" };
Array.Copy(a, 0, b, 0, a.Length);
return b;
}
@@ -290,6 +292,43 @@
return _originalString;
}
+ ///
+ /// Returns the normalized string representation of this instance of .
+ /// If the instance can be strictly parsed as a , the normalized version
+ /// string if of the format {major}.{minor}.{build}[-{special-version}]. If the instance has a non-zero
+ /// value for , the format is {major}.{minor}.{build}.{revision}[-{special-version}].
+ ///
+ /// The normalized string representation.
+ public string ToNormalizedString()
+ {
+ if (_normalizedVersionString == null)
+ {
+ var builder = new StringBuilder();
+ builder
+ .Append(Version.Major)
+ .Append('.')
+ .Append(Version.Minor)
+ .Append('.')
+ .Append(Math.Max(0, Version.Build));
+
+ if (Version.Revision > 0)
+ {
+ builder.Append('.')
+ .Append(Version.Revision);
+ }
+
+ if (!string.IsNullOrEmpty(SpecialVersion))
+ {
+ builder.Append('-')
+ .Append(SpecialVersion);
+ }
+
+ _normalizedVersionString = builder.ToString();
+ }
+
+ return _normalizedVersionString;
+ }
+
public bool Equals(SemanticVersion other)
{
return !Object.ReferenceEquals(null, other) &&
diff -Nru nuget-2.8.5+md59+dhx1/src/Core/Utility/PackageHelper.cs nuget-2.8.7+md510+dhx1/src/Core/Utility/PackageHelper.cs
--- nuget-2.8.5+md59+dhx1/src/Core/Utility/PackageHelper.cs 2015-06-11 08:14:57.000000000 +0000
+++ nuget-2.8.7+md510+dhx1/src/Core/Utility/PackageHelper.cs 2015-09-02 14:21:52.000000000 +0000
@@ -1,6 +1,7 @@
using System;
using System.Globalization;
using System.IO;
+using System.IO.Packaging;
using System.Linq;
using System.Runtime.Versioning;
using NuGet.Resources;
@@ -89,5 +90,25 @@
return package;
}
+
+ internal static Stream GetManifestStream(Stream packageStream)
+ {
+ Package package = Package.Open(packageStream);
+ PackageRelationship relationshipType = package.GetRelationshipsByType(Constants.PackageRelationshipNamespace + PackageBuilder.ManifestRelationType).SingleOrDefault();
+
+ if (relationshipType == null)
+ {
+ throw new InvalidOperationException(NuGetResources.PackageDoesNotContainManifest);
+ }
+
+ PackagePart manifestPart = package.GetPart(relationshipType.TargetUri);
+
+ if (manifestPart == null)
+ {
+ throw new InvalidOperationException(NuGetResources.PackageDoesNotContainManifest);
+ }
+
+ return manifestPart.GetStream();
+ }
}
}
diff -Nru nuget-2.8.5+md59+dhx1/src/Core/Utility/VersionUtility.cs nuget-2.8.7+md510+dhx1/src/Core/Utility/VersionUtility.cs
--- nuget-2.8.5+md59+dhx1/src/Core/Utility/VersionUtility.cs 2015-06-11 08:15:06.000000000 +0000
+++ nuget-2.8.7+md510+dhx1/src/Core/Utility/VersionUtility.cs 2015-09-02 14:21:52.000000000 +0000
@@ -1,6 +1,7 @@
using System;
using System.Collections.Generic;
using System.Diagnostics;
+using System.Diagnostics.CodeAnalysis;
using System.Globalization;
using System.IO;
using System.Linq;
@@ -17,14 +18,16 @@
private const string NetFrameworkIdentifier = ".NETFramework";
private const string NetCoreFrameworkIdentifier = ".NETCore";
private const string PortableFrameworkIdentifier = ".NETPortable";
+ private const string NetPlatformFrameworkIdentifier = ".NETPlatform";
+ private const string NetPlatformFrameworkShortName = "dotnet";
private const string AspNetFrameworkIdentifier = "ASP.Net";
private const string AspNetCoreFrameworkIdentifier = "ASP.NetCore";
private const string DnxFrameworkIdentifier = "DNX";
private const string DnxFrameworkShortName = "dnx";
private const string DnxCoreFrameworkIdentifier = "DNXCore";
private const string DnxCoreFrameworkShortName = "dnxcore";
- private const string CoreFrameworkIdentifier = "Core";
- private const string CoreFrameworkShortName = "core";
+ private const string UAPFrameworkIdentifier = "UAP";
+ private const string UAPFrameworkShortName = "uap";
private const string LessThanOrEqualTo = "\u2264";
private const string GreaterThanOrEqualTo = "\u2265";
@@ -94,8 +97,12 @@
{ DnxFrameworkShortName, DnxFrameworkIdentifier },
{ DnxCoreFrameworkShortName, DnxCoreFrameworkIdentifier },
- // Core
- { CoreFrameworkShortName, CoreFrameworkIdentifier },
+ // Dotnet
+ { NetPlatformFrameworkShortName, NetPlatformFrameworkIdentifier },
+ { NetPlatformFrameworkIdentifier, NetPlatformFrameworkIdentifier },
+
+ // UAP
+ { UAPFrameworkShortName, UAPFrameworkIdentifier },
// Native
{ "native", "native"},
@@ -117,6 +124,8 @@
{ "Xamarin.PlayStationVita", "Xamarin.PlayStationVita" },
{ "XamarinPlayStationVita", "Xamarin.PlayStationVita" },
{ "XamarinPSVita", "Xamarin.PlayStationVita" },
+ { "Xamarin.WatchOS", "Xamarin.WatchOS" },
+ { "XamarinWatchOS", "Xamarin.WatchOS" },
{ "Xamarin.XboxThreeSixty", "Xamarin.Xbox360" },
{ "XamarinXboxThreeSixty", "Xamarin.Xbox360" },
{ "Xamarin.XboxOne", "Xamarin.XboxOne" },
@@ -136,11 +145,12 @@
{ ".NETMicroFramework", "netmf" },
{ DnxFrameworkIdentifier, DnxFrameworkShortName },
{ DnxCoreFrameworkIdentifier, DnxCoreFrameworkShortName },
- { CoreFrameworkIdentifier, CoreFrameworkShortName },
+ { NetPlatformFrameworkIdentifier, NetPlatformFrameworkShortName },
{ AspNetFrameworkIdentifier, "aspnet" },
{ AspNetCoreFrameworkIdentifier, "aspnetcore" },
{ "Silverlight", "sl" },
- { ".NETCore", "win"},
+ { ".NETCore45", "win"},
+ { ".NETCore451", "win81"},
{ "Windows", "win"},
{ ".NETPortable", "portable" },
{ "WindowsPhone", "wp"},
@@ -150,8 +160,9 @@
{ "Xamarin.PlayStation3", "xamarinpsthree" },
{ "Xamarin.PlayStation4", "xamarinpsfour" },
{ "Xamarin.PlayStationVita", "xamarinpsvita" },
+ { "Xamarin.WatchOS", "xamarinwatchos" },
{ "Xamarin.Xbox360", "xamarinxboxthreesixty" },
- { "Xamarin.XboxOne", "xamarinxboxone" }
+ { "Xamarin.XboxOne", "xamarinxboxone" },
};
private static readonly Dictionary _identifierToProfileFolder = new Dictionary(StringComparer.OrdinalIgnoreCase) {
@@ -206,7 +217,7 @@
{ DnxFrameworkIdentifier, new FrameworkName(AspNetFrameworkIdentifier, MaxVersion) },
// Allow a net package to be installed in an aspnet (or dnx, transitively by above) project
- { AspNetFrameworkIdentifier, new FrameworkName(NetFrameworkIdentifier, MaxVersion) }
+ { AspNetFrameworkIdentifier, new FrameworkName(NetFrameworkIdentifier, MaxVersion) },
};
public static Version DefaultTargetFrameworkVersion
@@ -319,7 +330,8 @@
return UnsupportedFrameworkName;
}
- version = _emptyVersion;
+ // Use 5.0 instead of 0.0 as the default for NetPlatform
+ version = identifierPart.Equals(NetPlatformFrameworkIdentifier) ? new Version(5, 0) : _emptyVersion;
}
if (String.IsNullOrEmpty(identifierPart))
@@ -616,6 +628,14 @@
}
}
+ if (frameworkName.Version.Major == 5
+ && frameworkName.Version.Minor == 0
+ && frameworkName.Identifier.Equals(NetPlatformFrameworkIdentifier, StringComparison.OrdinalIgnoreCase))
+ {
+ // Normalize version 5.0 to 0.0 for display purposes for dotnet
+ frameworkName = new FrameworkName(frameworkName.Identifier, _emptyVersion, frameworkName.Profile);
+ }
+
string name;
if (!_identifierToFrameworkFolder.TryGetValue(frameworkName.Identifier, out name))
{
@@ -642,7 +662,19 @@
if (frameworkName.Version > new Version())
{
// Remove the . from versions
- name += frameworkName.Version.ToString().Replace(".", String.Empty);
+ if (frameworkName.Version.Major > 9
+ || frameworkName.Version.Minor > 9
+ || frameworkName.Version.Revision > 9
+ || frameworkName.Version.Build > 9)
+ {
+ // This version has digits over 10 and must be expressed using decimals
+ name += GetDecimalVersionString(frameworkName.Version);
+ }
+ else
+ {
+ // Express the version without decimals
+ name += frameworkName.Version.ToString().Replace(".", String.Empty);
+ }
}
if (String.IsNullOrEmpty(frameworkName.Profile))
@@ -659,6 +691,53 @@
return name + "-" + profile;
}
+ private static string GetDecimalVersionString(Version version)
+ {
+ StringBuilder sb = new StringBuilder();
+
+ if (version != null)
+ {
+ Stack versionParts = new Stack();
+
+ versionParts.Push(version.Major > 0 ? version.Major : 0);
+ versionParts.Push(version.Minor > 0 ? version.Minor : 0);
+ versionParts.Push(version.Build > 0 ? version.Build : 0);
+ versionParts.Push(version.Revision > 0 ? version.Revision : 0);
+
+ // if any parts of the version are over 9 we need to use decimals
+ bool useDecimals = versionParts.Any(x => x > 9);
+
+ // remove all trailing zeros
+ while (versionParts.Count > 0 && versionParts.Peek() <= 0)
+ {
+ versionParts.Pop();
+ }
+
+ // write the version string out backwards
+ while (versionParts.Count > 0)
+ {
+ // avoid adding a decimal if this is the first digit, but if we are down
+ // to only 2 numbers left we have to add a decimal otherwise 10.0 becomes 1.0
+ // during the parse
+ if (useDecimals)
+ {
+ if (sb.Length > 0)
+ {
+ sb.Insert(0, ".");
+ }
+ else if (versionParts.Count == 1)
+ {
+ sb.Append(".0");
+ }
+ }
+
+ sb.Insert(0, versionParts.Pop());
+ }
+ }
+
+ return sb.ToString();
+ }
+
public static string GetTargetFrameworkLogString(FrameworkName targetFramework)
{
return (targetFramework == null || targetFramework == VersionUtility.EmptyFramework) ? NuGetResources.Debug_TargetFrameworkInfo_NotFrameworkSpecific : String.Empty;
@@ -749,6 +828,7 @@
return null;
}
+ [SuppressMessage("Microsoft.Maintainability", "CA1502:AvoidExcessiveComplexity")]
public static bool TryGetCompatibleItems(FrameworkName projectFramework, IEnumerable items, out IEnumerable compatibleItems) where T : IFrameworkTargetable
{
if (!items.Any())
diff -Nru nuget-2.8.5+md59+dhx1/src/VisualStudio/Extensibility/VsPackageRestorer.cs nuget-2.8.7+md510+dhx1/src/VisualStudio/Extensibility/VsPackageRestorer.cs
--- nuget-2.8.5+md59+dhx1/src/VisualStudio/Extensibility/VsPackageRestorer.cs 2015-06-11 08:14:57.000000000 +0000
+++ nuget-2.8.7+md510+dhx1/src/VisualStudio/Extensibility/VsPackageRestorer.cs 2015-09-02 14:21:52.000000000 +0000
@@ -70,7 +70,7 @@
var repoSettings = ServiceLocator.GetInstance();
var fileSystem = new PhysicalFileSystem(repoSettings.RepositoryPath);
var activePackageSourceRepository = ServiceLocator.GetInstance();
- var repository = new PriorityPackageRepository(NuGet.MachineCache.Default, activePackageSourceRepository);
+ var repository = new AggregateRepository(new[] { MachineCache.Default, activePackageSourceRepository });
IVsPackageManagerFactory packageManagerFactory = ServiceLocator.GetInstance();
var packageManager = packageManagerFactory.CreatePackageManager(repository, useFallbackForDependencies: false);
diff -Nru nuget-2.8.5+md59+dhx1/src/VisualStudio/PackageRestore/PackageRestoreManager.cs nuget-2.8.7+md510+dhx1/src/VisualStudio/PackageRestore/PackageRestoreManager.cs
--- nuget-2.8.5+md59+dhx1/src/VisualStudio/PackageRestore/PackageRestoreManager.cs 2015-06-11 08:15:06.000000000 +0000
+++ nuget-2.8.7+md510+dhx1/src/VisualStudio/PackageRestore/PackageRestoreManager.cs 2015-09-02 14:21:52.000000000 +0000
@@ -9,11 +9,8 @@
using System.Runtime.CompilerServices;
using System.Threading.Tasks;
using System.Windows;
-using System.Windows.Threading;
using EnvDTE;
-using Microsoft.VisualStudio.Project;
-using Microsoft.VisualStudio.Project.Designers;
using Microsoft.VisualStudio.Shell.Interop;
using NuGet.VisualStudio.Resources;
using MsBuildProject = Microsoft.Build.Evaluation.Project;
@@ -170,9 +167,11 @@
}
finally
{
- int canceled;
-
- InvokeOnUIThread(() => waitDialog.EndWaitDialog(out canceled));
+ InvokeOnUIThread(() =>
+ {
+ int canceled;
+ waitDialog.EndWaitDialog(out canceled);
+ });
}
if (fromActivation)
@@ -629,7 +628,14 @@
{
if (Application.Current != null)
{
- Application.Current.Dispatcher.Invoke(action);
+ try
+ {
+ Application.Current.Dispatcher.Invoke(action);
+ }
+ catch (TaskCanceledException)
+ {
+ // Thrown if VS is closed while the action is being processed.
+ }
}
else
{
diff -Nru nuget-2.8.5+md59+dhx1/src/VisualStudio/SkipAssemblyReferencesPackage.cs nuget-2.8.7+md510+dhx1/src/VisualStudio/SkipAssemblyReferencesPackage.cs
--- nuget-2.8.5+md59+dhx1/src/VisualStudio/SkipAssemblyReferencesPackage.cs 2015-06-11 08:15:06.000000000 +0000
+++ nuget-2.8.7+md510+dhx1/src/VisualStudio/SkipAssemblyReferencesPackage.cs 2015-09-02 14:21:52.000000000 +0000
@@ -157,6 +157,11 @@
return _basePackage.GetStream();
}
+ public void ExtractContents(IFileSystem fileSystem, string extactPath)
+ {
+ _basePackage.ExtractContents(fileSystem, extactPath);
+ }
+
public IEnumerable GetSupportedFrameworks()
{
return _basePackage.GetSupportedFrameworks();
diff -Nru nuget-2.8.5+md59+dhx1/src/VisualStudio/VsSettings.cs nuget-2.8.7+md510+dhx1/src/VisualStudio/VsSettings.cs
--- nuget-2.8.5+md59+dhx1/src/VisualStudio/VsSettings.cs 2015-06-11 08:15:06.000000000 +0000
+++ nuget-2.8.7+md510+dhx1/src/VisualStudio/VsSettings.cs 2015-09-02 14:21:52.000000000 +0000
@@ -128,7 +128,7 @@
}
}
- public void SetValues(string section, IList> values)
+ public void SetValues(string section, IList values)
{
if (section.Equals(SolutionConfigSection, StringComparison.OrdinalIgnoreCase))
{
@@ -140,6 +140,18 @@
}
}
+ public void UpdateSections(string section, IList values)
+ {
+ if (section.Equals(SolutionConfigSection, StringComparison.OrdinalIgnoreCase))
+ {
+ SolutionSettings.UpdateSections(section, values);
+ }
+ else
+ {
+ _defaultSettings.UpdateSections(section, values);
+ }
+ }
+
public void SetNestedValues(string section, string key, IList> values)
{
if (section.Equals(SolutionConfigSection, StringComparison.OrdinalIgnoreCase))
diff -Nru nuget-2.8.5+md59+dhx1/src/VsEvents/PackageRestorer.cs nuget-2.8.7+md510+dhx1/src/VsEvents/PackageRestorer.cs
--- nuget-2.8.5+md59+dhx1/src/VsEvents/PackageRestorer.cs 2015-06-11 08:14:57.000000000 +0000
+++ nuget-2.8.7+md510+dhx1/src/VsEvents/PackageRestorer.cs 2015-09-02 14:21:52.000000000 +0000
@@ -356,7 +356,7 @@
// as secondary source.
IVsPackageManagerFactory packageManagerFactory = ServiceLocator.GetInstance();
var allSources = packageManagerFactory.CreatePackageManagerWithAllPackageSources().SourceRepository;
- var repository = new PriorityPackageRepository(NuGet.MachineCache.Default, allSources);
+ var repository = new AggregateRepository(new[] { MachineCache.Default, allSources });
var packageManager = packageManagerFactory.CreatePackageManager(repository, useFallbackForDependencies: false);
using (packageManager.SourceRepository.StartOperation(RepositoryOperationNames.Restore, package.Id, package.Version.ToString()))
{