From 21985b0455641d60228eeedec94a547fd75491c0 Mon Sep 17 00:00:00 2001 From: Alexandre Mutel Date: Thu, 30 Jul 2015 15:53:04 +0900 Subject: [PATCH 01/13] Fix overflow in HttpClient when downloading a package with a size larger than 21,474,836 bytes (int.Max/100) that was generating negative download percentage completion --- src/Core/Http/HttpClient.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/Core/Http/HttpClient.cs b/src/Core/Http/HttpClient.cs index 983bfab50..3d787b149 100644 --- a/src/Core/Http/HttpClient.cs +++ b/src/Core/Http/HttpClient.cs @@ -182,7 +182,7 @@ public void DownloadData(Stream targetStream) targetStream.Write(buffer, 0, bytesRead); totalReadSoFar += bytesRead; - OnProgressAvailable((totalReadSoFar * 100) / length); + OnProgressAvailable((int)(((long)totalReadSoFar * 100) / length)); // avoid 32 bit overflow by calculating * 100 with 64 bit } } } From 580e104a1a6d59d142f6dc31d7221548a6f34a26 Mon Sep 17 00:00:00 2001 From: Meni Zalzman Date: Fri, 9 Oct 2015 12:36:46 -0700 Subject: [PATCH 02/13] Create 2.10 branch --- Build/Build.proj | 2 +- Common/CommonAssemblyInfo.cs | 4 ++-- src/VsExtension/vs10.vsixmanifest | 2 +- src/VsExtension/vs12.vsixmanifest | 2 +- src/VsExtension/vs14.vsixmanifest | 2 +- 5 files changed, 6 insertions(+), 6 deletions(-) diff --git a/Build/Build.proj b/Build/Build.proj index 19bfa0c29..3e9b865e7 100644 --- a/Build/Build.proj +++ b/Build/Build.proj @@ -52,7 +52,7 @@ in Common\CommonAssemblyInfo.cs so the version numbers are consistent between binaries built on build servers and those built locally. --> 2 - 9 + 10 0 $(BUILD_NUMBER) diff --git a/Common/CommonAssemblyInfo.cs b/Common/CommonAssemblyInfo.cs index b5381e6f2..e85a08f53 100644 --- a/Common/CommonAssemblyInfo.cs +++ b/Common/CommonAssemblyInfo.cs @@ -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.9.0.0")] -[assembly: AssemblyInformationalVersion("2.9.0")] +[assembly: AssemblyVersion("2.10.0.0")] +[assembly: AssemblyInformationalVersion("2.10.0")] #endif [assembly: NeutralResourcesLanguage("en-US")] diff --git a/src/VsExtension/vs10.vsixmanifest b/src/VsExtension/vs10.vsixmanifest index 1e75756ef..333747b80 100644 --- a/src/VsExtension/vs10.vsixmanifest +++ b/src/VsExtension/vs10.vsixmanifest @@ -5,7 +5,7 @@ Outercurve Foundation - 2.9.0.0 + 2.10.0.0 A collection of tools to automate the process of downloading, installing, upgrading, configuring, and removing packages from a VS Project. 1033 diff --git a/src/VsExtension/vs12.vsixmanifest b/src/VsExtension/vs12.vsixmanifest index f4bec63ea..428b5a166 100644 --- a/src/VsExtension/vs12.vsixmanifest +++ b/src/VsExtension/vs12.vsixmanifest @@ -5,7 +5,7 @@ Outercurve Foundation - 2.9.0.0 + 2.10.0.0 A collection of tools to automate the process of downloading, installing, upgrading, configuring, and removing packages from a VS Project. 1033 diff --git a/src/VsExtension/vs14.vsixmanifest b/src/VsExtension/vs14.vsixmanifest index 2e72aed9a..11c7d1a6d 100644 --- a/src/VsExtension/vs14.vsixmanifest +++ b/src/VsExtension/vs14.vsixmanifest @@ -5,7 +5,7 @@ Outercurve Foundation - 2.9.0.0 + 2.10.0.0 A collection of tools to automate the process of downloading, installing, upgrading, configuring, and removing packages from a VS Project. 1033 From 081e203ccf1a2dd95a41cacf7ca4721cf548ed9f Mon Sep 17 00:00:00 2001 From: Zhi Li Date: Tue, 6 Oct 2015 11:03:40 -0700 Subject: [PATCH 03/13] fixed https://github.com/NuGet/Home/issues/1514 port https://nuget.codeplex.com/SourceControl/network/forks/StephenCleary/Issue4013/changeset/2803f4895ea678d0b0cfbb5a5e2961ec0dec40f7 --- .../Authoring/AssemblyMetadataExtractor.cs | 4 +- .../PortableLib.zip/Class1.cs | 11 ++++ .../PortableLib.zip/MyTemplate.vstemplate | 24 +++++++++ .../PortableLib.zip/PortableLib.csproj | 48 ++++++++++++++++++ .../PortableLib.zip/__TemplateIcon.ico | Bin 0 -> 44043 bytes test/EndToEnd/tests/PackTest.ps1 | 17 +++++++ test/EndToEnd/vs.ps1 | 28 ++++++++++ 7 files changed, 130 insertions(+), 2 deletions(-) create mode 100644 test/EndToEnd/ProjectTemplates/PortableLib.zip/Class1.cs create mode 100644 test/EndToEnd/ProjectTemplates/PortableLib.zip/MyTemplate.vstemplate create mode 100644 test/EndToEnd/ProjectTemplates/PortableLib.zip/PortableLib.csproj create mode 100644 test/EndToEnd/ProjectTemplates/PortableLib.zip/__TemplateIcon.ico diff --git a/src/Core/Authoring/AssemblyMetadataExtractor.cs b/src/Core/Authoring/AssemblyMetadataExtractor.cs index 4b154d819..6d56321b3 100644 --- a/src/Core/Authoring/AssemblyMetadataExtractor.cs +++ b/src/Core/Authoring/AssemblyMetadataExtractor.cs @@ -59,11 +59,11 @@ public AssemblyResolver(string assemblyPath) public Assembly ReflectionOnlyAssemblyResolve(object sender, ResolveEventArgs args) { - var name = new AssemblyName(args.Name); + var name = new AssemblyName(AppDomain.CurrentDomain.ApplyPolicy(args.Name)); var assemblyPath = Path.Combine(_lookupPath, name.Name + ".dll"); return File.Exists(assemblyPath) ? Assembly.ReflectionOnlyLoadFrom(assemblyPath) : // load from same folder as parent assembly - Assembly.ReflectionOnlyLoad(args.Name); // load from GAC + Assembly.ReflectionOnlyLoad(name.FullName); // load from GAC } } diff --git a/test/EndToEnd/ProjectTemplates/PortableLib.zip/Class1.cs b/test/EndToEnd/ProjectTemplates/PortableLib.zip/Class1.cs new file mode 100644 index 000000000..44b75d214 --- /dev/null +++ b/test/EndToEnd/ProjectTemplates/PortableLib.zip/Class1.cs @@ -0,0 +1,11 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; + +namespace $safeprojectname$ +{ + public class Class1 + { + } +} diff --git a/test/EndToEnd/ProjectTemplates/PortableLib.zip/MyTemplate.vstemplate b/test/EndToEnd/ProjectTemplates/PortableLib.zip/MyTemplate.vstemplate new file mode 100644 index 000000000..65ead577e --- /dev/null +++ b/test/EndToEnd/ProjectTemplates/PortableLib.zip/MyTemplate.vstemplate @@ -0,0 +1,24 @@ + + + PortableLib + <No description available> + CSharp + + + 1000 + true + PortableLib + true + Enabled + true + __TemplateIcon.ico + + + + Class1.cs + + AssemblyInfo.cs + + + + \ No newline at end of file diff --git a/test/EndToEnd/ProjectTemplates/PortableLib.zip/PortableLib.csproj b/test/EndToEnd/ProjectTemplates/PortableLib.zip/PortableLib.csproj new file mode 100644 index 000000000..a19c6b85a --- /dev/null +++ b/test/EndToEnd/ProjectTemplates/PortableLib.zip/PortableLib.csproj @@ -0,0 +1,48 @@ + + + + + 12.0 + Debug + AnyCPU + {2739BE74-A33D-437A-A246-AB0BFC8C3E65} + Library + Properties + $safeprojectname$ + $safeprojectname$ + en-US + 512 + {786C830F-07A1-408B-BD7F-6EE04809D6DB};{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC} + Profile151 + v4.6 + + + true + full + false + bin\Debug\ + DEBUG;TRACE + prompt + 4 + + + pdbonly + true + bin\Release\ + TRACE + prompt + 4 + + + + + + + + \ No newline at end of file diff --git a/test/EndToEnd/ProjectTemplates/PortableLib.zip/__TemplateIcon.ico b/test/EndToEnd/ProjectTemplates/PortableLib.zip/__TemplateIcon.ico new file mode 100644 index 0000000000000000000000000000000000000000..aae70d3b83cf76e276e5209bae014f83bc61eb75 GIT binary patch literal 44043 zcmeHQ30zah)}OEhP!=n#fL5TkMQgSCT)?txT|W`6)(u6WqNr3+F`{gVAq?IO2}vYi;LG)QGjryg^FPbXy>}81 z2>>*p2hc$Sx}ZrHfbU^{^k@+sWeC7Q$hNd>r6J$W6o7vHMD%KH03JaeI%vQW@F0Jt z6#&l8B6`>)06rXr@hm~q`vA<_i18o|aT=jP5uPPjtp&izNC0-tah+z+XJ8))YcON_ z38>TPz1Hdp9owOUi zQCa%|9N3H#4{=GQP(?X}wU;7OV&D1doof+!a zF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KzB|fGXL+*xhrfd?*RvMMb=H?x(eKEA zROd;(Ze;blvM!Wrn;K_F{=?s$R>*%OPsLVd|5f~lUy7`d|43e$K2x!Jy8qNzsQsR@ zeyBcE`yKhOO4l#dXKKGA|B;-k+&^Ds{o^=Q;rZ1W|4|&Td;ic`|M6U?S}SY)tD3*0 zKfTp|Y3ohZ#--(7)%=v^PjB^~yiQb=mX?22^_TRkxB4&bdQr7;Y57+*Kc)H8Tm2`m z6IG?9#;sH6-w{(S`m9&EB^cSmMu}T&=18D2f6NEl_p^2CSTPa zsVBEVLJ;Fn@8gQ}u|5GSH;MHXu}PK1`f?j21hGC9Q;|N_Ct&3!vA#5$xUNDPAM49) zkPyWB((vWAk8xhLm1bYo_^a9@^<>$R#+QbJ$FZI?njFXSxJ93Fb@VwG*2gW@lb0st zus&+3|NkS+2dv-OmTH%@jj<*9fO$Qo#c{qae@XlJc0l?Ae;Zv$t!F`fG)BsGmX>56 z*};C2t+IWPWS<&0X&>=A6Enuc7?SK`8EGxneU%ntV%_exkL}`ClKrmCKemfoN%p&P z{mGMmpNc&wq z-z2`O*{9~FJNjh&-C>hz0{|!Zw|tUL?3v`21BaDyqR%PN#}bzC#J@Z2tOW_;p!zJW zPpF8INC&SyNiE`wDG)?==u3+Wk5m07-wRM>u&>k>_YnrJ38U6PV0~q`$R5H(>4fdR zw6wIg?*vER_l;Ec`0pMBUTYK!BP){3-6uT(vG`=q`!JJQBUeR=I-IlzPn_@sitKCAUa!?@3ZeIDif EAKlW`b^rhX literal 0 HcmV?d00001 diff --git a/test/EndToEnd/tests/PackTest.ps1 b/test/EndToEnd/tests/PackTest.ps1 index 12170ad1a..1e1a5a938 100644 --- a/test/EndToEnd/tests/PackTest.ps1 +++ b/test/EndToEnd/tests/PackTest.ps1 @@ -85,6 +85,23 @@ function Test-PackFromProjectWithDevelopmentDependencySet { } +function Test-PackPCLProject +{ + param( + $context + ) + + # Arrange + $p = New-PCLLibrary + + # Act + $projFile = Write-Output $p.FullName + $output = Invoke-Expression "& `"$nugetExePath`" pack $projFile -build 2>&1" + + # Assert + Assert-Null($output -Match "WARNING: Unable to extract metadata") +} + function NoTest-PackFromProjectUsesInstalledPackagesAsDependencies { param( $context diff --git a/test/EndToEnd/vs.ps1 b/test/EndToEnd/vs.ps1 index 934a3bbae..a59f45cf5 100644 --- a/test/EndToEnd/vs.ps1 +++ b/test/EndToEnd/vs.ps1 @@ -244,6 +244,34 @@ function New-PortableLibrary $project } +function New-PCLLibrary +{ + param( + [string]$ProjectName, + [string]$Profile = $null, + [parameter(ValueFromPipeline = $true)]$SolutionFolder + ) + + try + { + $project = New-Project PortableLib $ProjectName $SolutionFolder + } + catch { + # If we're unable to create the project that means we probably don't have some SDK installed + # Signal to the runner that we want to skip this test + throw "SKIP: $($_)" + } + + if ($Profile) + { + $name = $project.Name + $project.Properties.Item("TargetFrameworkMoniker").Value = ".NETPortable,Version=v4.0,Profile=$Profile" + $project = Get-Project -Name $name + } + + $project +} + function New-JavaScriptApplication { param( From ede4eb655c9600209186ed799945d859f28946be Mon Sep 17 00:00:00 2001 From: Zhi Li Date: Tue, 13 Oct 2015 23:24:39 -0700 Subject: [PATCH 04/13] ported https://github.com/NuGet/NuGet2/pull/10 --- src/Core/Utility/VersionUtility.cs | 6 ++ test/Core.Test/NetPortableProfileTableTest.cs | 68 +++++++++++++++++++ test/Core.Test/VersionUtilityTest.cs | 26 +++++++ 3 files changed, 100 insertions(+) diff --git a/src/Core/Utility/VersionUtility.cs b/src/Core/Utility/VersionUtility.cs index b3c5909d5..a79f904e3 100644 --- a/src/Core/Utility/VersionUtility.cs +++ b/src/Core/Utility/VersionUtility.cs @@ -124,6 +124,10 @@ public static class VersionUtility { "Xamarin.PlayStationVita", "Xamarin.PlayStationVita" }, { "XamarinPlayStationVita", "Xamarin.PlayStationVita" }, { "XamarinPSVita", "Xamarin.PlayStationVita" }, + { "Xamarin.TVOS", "Xamarin.TVOS" }, + { "XamarinTVOS", "Xamarin.TVOS" }, + { "Xamarin.WatchOS", "Xamarin.WatchOS" }, + { "XamarinWatchOS", "Xamarin.WatchOS" }, { "Xamarin.XboxThreeSixty", "Xamarin.Xbox360" }, { "XamarinXboxThreeSixty", "Xamarin.Xbox360" }, { "Xamarin.XboxOne", "Xamarin.XboxOne" }, @@ -158,6 +162,8 @@ public static class VersionUtility { "Xamarin.PlayStation3", "xamarinpsthree" }, { "Xamarin.PlayStation4", "xamarinpsfour" }, { "Xamarin.PlayStationVita", "xamarinpsvita" }, + { "Xamarin.TVOS", "xamarintvos" }, + { "Xamarin.WatchOS", "xamarinwatchos" }, { "Xamarin.Xbox360", "xamarinxboxthreesixty" }, { "Xamarin.XboxOne", "xamarinxboxone" }, }; diff --git a/test/Core.Test/NetPortableProfileTableTest.cs b/test/Core.Test/NetPortableProfileTableTest.cs index 879dc255e..59a4194cd 100644 --- a/test/Core.Test/NetPortableProfileTableTest.cs +++ b/test/Core.Test/NetPortableProfileTableTest.cs @@ -113,5 +113,73 @@ public void LoadPortableProfileWithXamarinAsSupportedFramework() Assert.True(netPortableProfile.OptionalFrameworks.Count == 1); Assert.True(netPortableProfile.OptionalFrameworks.Contains(new FrameworkName("Xamarin.Mac, Version=1.0"))); } + + [Fact] + public void LoadPortableProfileWithXamarinWatchOSAsSupportedFramework() + { + // Arrange + string content1 = @" +"; + + string content2 = @" +"; + + var mockFileSystem = new MockFileSystem(); + mockFileSystem.AddFile("frameworkFile1.xml", content1); + mockFileSystem.AddFile("frameworkFile2.xml", content2); + + var frameworkFiles = new string[] { "frameworkFile1.xml", "frameworkFile2.xml" }; + + // Act + var netPortableProfile = NetPortableProfileTable.LoadPortableProfile("4.5.0.0", "Profile1", mockFileSystem, frameworkFiles); + + // Assert + Assert.True(netPortableProfile.SupportedFrameworks.Count == 1); + Assert.True(netPortableProfile.SupportedFrameworks.Contains(new FrameworkName(".NETFramework, Version=4.5"))); + + Assert.True(netPortableProfile.OptionalFrameworks.Count == 1); + Assert.True(netPortableProfile.OptionalFrameworks.Contains(new FrameworkName("Xamarin.WatchOS, Version=1.0"))); + } + + [Fact] + public void LoadPortableProfileWithXamarinTVOSAsSupportedFramework() + { + // Arrange + string content1 = @" +"; + + string content2 = @" +"; + + var mockFileSystem = new MockFileSystem(); + mockFileSystem.AddFile("frameworkFile1.xml", content1); + mockFileSystem.AddFile("frameworkFile2.xml", content2); + + var frameworkFiles = new string[] { "frameworkFile1.xml", "frameworkFile2.xml" }; + + // Act + var netPortableProfile = NetPortableProfileTable.LoadPortableProfile("4.5.0.0", "Profile1", mockFileSystem, frameworkFiles); + + // Assert + Assert.True(netPortableProfile.SupportedFrameworks.Count == 1); + Assert.True(netPortableProfile.SupportedFrameworks.Contains(new FrameworkName(".NETFramework, Version=4.5"))); + + Assert.True(netPortableProfile.OptionalFrameworks.Count == 1); + Assert.True(netPortableProfile.OptionalFrameworks.Contains(new FrameworkName("Xamarin.TVOS, Version=1.0"))); + } } } diff --git a/test/Core.Test/VersionUtilityTest.cs b/test/Core.Test/VersionUtilityTest.cs index 3a7547d63..4be91fcaf 100644 --- a/test/Core.Test/VersionUtilityTest.cs +++ b/test/Core.Test/VersionUtilityTest.cs @@ -415,6 +415,10 @@ public void ParseFrameworkNameNormalizesSupportedASPNetFrameworkNames(string sho [InlineData(new[] { "XamarinPlayStationVita", "xamarinplaystationvita", "XAMARINPLAYSTATIONVITA " }, "0.0", "Xamarin.PlayStationVita")] [InlineData(new[] { "Xamarin.PlayStationVita", "xamarin.playstationvita", "XAMARIN.PLAYSTATIONVITA " }, "0.0", "Xamarin.PlayStationVita")] [InlineData(new[] { "XamarinPSVita", "xamarinpsvita", "XAMARINPSVITA " }, "0.0", "Xamarin.PlayStationVita")] + [InlineData(new[] { "XamarinTVOS", "xamarintvos", "XAMARINTVOS " }, "0.0", "Xamarin.TVOS")] + [InlineData(new[] { "Xamarin.TVOS", "xamarin.tvos", "XAMARIN.TVOS " }, "0.0", "Xamarin.TVOS")] + [InlineData(new[] { "XamarinWatchOS", "xamarinwatchos", "XAMARINWATCHOS " }, "0.0", "Xamarin.WatchOS")] + [InlineData(new[] { "Xamarin.WatchOS", "xamarin.watchos", "XAMARIN.WATCHOS " }, "0.0", "Xamarin.WatchOS")] [InlineData(new[] { "Xamarin.XboxThreeSixty", "xamarin.xboxthreesixty", "XAMARIN.XBOXTHREESIXTY " }, "0.0", "Xamarin.Xbox360")] [InlineData(new[] { "XamarinXboxThreeSixty", "xamarinxboxthreesixty", "XAMARINXBOXTHREESIXTY " }, "0.0", "Xamarin.Xbox360")] [InlineData(new[] { "XamarinXboxOne", "xamarinxboxone", "XAMARINXBOXONE " }, "0.0", "Xamarin.XboxOne")] @@ -1455,6 +1459,8 @@ public void GetShortNameForMangoReturnsWP71() [InlineData("Xamarin.PlayStation3, Version=v1.0", "xamarinpsthree10")] [InlineData("Xamarin.PlayStation4, Version=v1.0", "xamarinpsfour10")] [InlineData("Xamarin.PlayStationVita, Version=v1.0", "xamarinpsvita10")] + [InlineData("Xamarin.TVOS, Version=v1.0", "xamarintvos10")] + [InlineData("Xamarin.WatchOS, Version=v1.0", "xamarinwatchos10")] [InlineData("Xamarin.Xbox360, Version=v1.0", "xamarinxboxthreesixty10")] [InlineData("Xamarin.XboxOne, Version=v1.0", "xamarinxboxone10")] public void GetShortNameForXamarinFrameworks(string frameworkIdentifier, string expectedShortName) @@ -1470,6 +1476,8 @@ public void GetShortNameForXamarinFrameworks(string frameworkIdentifier, string [InlineData(".NETPortable, Version=4.0, Profile=Profile1", "portable-net45+xamarinmac10+xamarinios10")] [InlineData(".NETPortable, Version=4.0, Profile=Profile2", "portable-net40+win+xamarinpsthree10+xamarinpsfour10+xamarinpsvita10")] [InlineData(".NETPortable, Version=4.0, Profile=Profile3", "portable-net40+xamarinxboxthreesixty10+xamarinxboxone10")] + [InlineData(".NETPortable, Version=4.0, Profile=Profile4", "portable-net40+xamarinios10+xamarinwatchos10")] + [InlineData(".NETPortable, Version=4.0, Profile=Profile5", "portable-net40+xamarinios10+xamarintvos10")] public void TestGetShortNameForPortableXamarinFrameworks(string frameworkIdentifier, string expectedShortName) { // Arrange @@ -1500,9 +1508,27 @@ public void TestGetShortNameForPortableXamarinFrameworks(string frameworkIdentif new FrameworkName("Xamarin.XboxOne, Version=1.0"), }); + var profile4 = new NetPortableProfile( + "Profile4", + new[] { + new FrameworkName(".NETFramework, Version=4.0"), + new FrameworkName("Xamarin.iOS, Version=1.0"), + new FrameworkName("Xamarin.WatchOS, Version=1.0"), + }); + + var profile5 = new NetPortableProfile( + "Profile5", + new[] { + new FrameworkName(".NETFramework, Version=4.0"), + new FrameworkName("Xamarin.iOS, Version=1.0"), + new FrameworkName("Xamarin.TVOS, Version=1.0"), + }); + profileCollection.Add(profile1); profileCollection.Add(profile2); profileCollection.Add(profile3); + profileCollection.Add(profile4); + profileCollection.Add(profile5); NetPortableProfileTable.Profiles = profileCollection; From 88a5cdc023535a69155f985b0ddc6b2d88cdfc90 Mon Sep 17 00:00:00 2001 From: Xavier Decoster Date: Wed, 14 Oct 2015 15:29:48 +0200 Subject: [PATCH 05/13] attempt to purge temp cache completely when no cached expanded folders in memory --- src/Core/Packages/OptimizedZipPackage.cs | 14 ++++++-------- 1 file changed, 6 insertions(+), 8 deletions(-) diff --git a/src/Core/Packages/OptimizedZipPackage.cs b/src/Core/Packages/OptimizedZipPackage.cs index 3b90ce934..14022ba27 100644 --- a/src/Core/Packages/OptimizedZipPackage.cs +++ b/src/Core/Packages/OptimizedZipPackage.cs @@ -318,18 +318,16 @@ public static void PurgeCache() { foreach (var valueTuple in _cachedExpandedFolder.Values) { - try - { - string expandedFolder = valueTuple.Item1; - _tempFileSystem.DeleteDirectory(expandedFolder, recursive: true); - } - catch (Exception) - { - } + string expandedFolder = valueTuple.Item1; + _tempFileSystem.DeleteDirectorySafe(expandedFolder, recursive: true); } _cachedExpandedFolder.Clear(); } + else + { + _tempFileSystem.DeleteDirectorySafe(_tempFileSystem.Root, recursive: true); + } } } } From b4b0d64e64e87da8a3013e39fe6f321a4a6fef51 Mon Sep 17 00:00:00 2001 From: Justin Emgarten Date: Thu, 15 Oct 2015 11:36:30 -0700 Subject: [PATCH 06/13] Adding .vs to gitignore --- .gitignore | 1 + 1 file changed, 1 insertion(+) diff --git a/.gitignore b/.gitignore index 786eaeb6b..d1e767e13 100644 --- a/.gitignore +++ b/.gitignore @@ -25,6 +25,7 @@ bld/ # Roslyn cache directories *.ide/ +.vs/ # MSTest test Results [Tt]est[Rr]esult*/ From 5c69c67d10ac8708286d7ec57866bae88d020fb8 Mon Sep 17 00:00:00 2001 From: Justin Emgarten Date: Thu, 15 Oct 2015 12:14:04 -0700 Subject: [PATCH 07/13] Nuspec validation support for the shared content --- .../Rules/MisplacedTransformFileRule.cs | 5 ++++- src/Core/Authoring/nuspec.xsd | 17 +++++++++++++++++ src/Core/Packages/Constants.cs | 7 ++++++- 3 files changed, 27 insertions(+), 2 deletions(-) diff --git a/src/Core/Analysis/Rules/MisplacedTransformFileRule.cs b/src/Core/Analysis/Rules/MisplacedTransformFileRule.cs index 9620d5efe..d9fed1e62 100644 --- a/src/Core/Analysis/Rules/MisplacedTransformFileRule.cs +++ b/src/Core/Analysis/Rules/MisplacedTransformFileRule.cs @@ -26,7 +26,10 @@ public IEnumerable Validate(IPackage package) } // if not inside 'content' folder, warn - if (!path.StartsWith(Constants.ContentDirectory + Path.DirectorySeparatorChar, StringComparison.OrdinalIgnoreCase)) + if (!path.StartsWith(Constants.ContentDirectory + Path.DirectorySeparatorChar, + StringComparison.OrdinalIgnoreCase) + && !path.StartsWith(Constants.SharedDirectory + Path.DirectorySeparatorChar, + StringComparison.OrdinalIgnoreCase)) { yield return CreatePackageIssueForMisplacedContent(path); } diff --git a/src/Core/Authoring/nuspec.xsd b/src/Core/Authoring/nuspec.xsd index 35d69cfff..dbaf117b8 100644 --- a/src/Core/Authoring/nuspec.xsd +++ b/src/Core/Authoring/nuspec.xsd @@ -23,6 +23,14 @@ + + + + + + + + @@ -85,6 +93,15 @@ + + + + + + + + + diff --git a/src/Core/Packages/Constants.cs b/src/Core/Packages/Constants.cs index c83c92c3d..098df9afe 100644 --- a/src/Core/Packages/Constants.cs +++ b/src/Core/Packages/Constants.cs @@ -40,7 +40,12 @@ public static class Constants /// Represents the build directory in the package. /// public static readonly string BuildDirectory = "build"; - + + /// + /// Represents the shared directory in the package. + /// + public static readonly string SharedDirectory = "shared"; + public static readonly string BinDirectory = "bin"; public static readonly string SettingsFileName = "NuGet.Config"; public static readonly string PackageReferenceFile = "packages.config"; From 9ec67ca3a240dfbd41ce0d35569a7445ad64f08d Mon Sep 17 00:00:00 2001 From: Justin Emgarten Date: Mon, 19 Oct 2015 21:16:44 -0700 Subject: [PATCH 08/13] Renaming shared to contentFiles --- src/Core/Analysis/Rules/MisplacedTransformFileRule.cs | 2 +- src/Core/Authoring/nuspec.xsd | 6 +++--- src/Core/Packages/Constants.cs | 2 +- 3 files changed, 5 insertions(+), 5 deletions(-) diff --git a/src/Core/Analysis/Rules/MisplacedTransformFileRule.cs b/src/Core/Analysis/Rules/MisplacedTransformFileRule.cs index d9fed1e62..3e5e59817 100644 --- a/src/Core/Analysis/Rules/MisplacedTransformFileRule.cs +++ b/src/Core/Analysis/Rules/MisplacedTransformFileRule.cs @@ -28,7 +28,7 @@ public IEnumerable Validate(IPackage package) // if not inside 'content' folder, warn if (!path.StartsWith(Constants.ContentDirectory + Path.DirectorySeparatorChar, StringComparison.OrdinalIgnoreCase) - && !path.StartsWith(Constants.SharedDirectory + Path.DirectorySeparatorChar, + && !path.StartsWith(Constants.ContentFilesDirectory + Path.DirectorySeparatorChar, StringComparison.OrdinalIgnoreCase)) { yield return CreatePackageIssueForMisplacedContent(path); diff --git a/src/Core/Authoring/nuspec.xsd b/src/Core/Authoring/nuspec.xsd index dbaf117b8..383ca2b06 100644 --- a/src/Core/Authoring/nuspec.xsd +++ b/src/Core/Authoring/nuspec.xsd @@ -23,7 +23,7 @@ - + @@ -93,11 +93,11 @@ - + - + diff --git a/src/Core/Packages/Constants.cs b/src/Core/Packages/Constants.cs index 098df9afe..1974e35b4 100644 --- a/src/Core/Packages/Constants.cs +++ b/src/Core/Packages/Constants.cs @@ -44,7 +44,7 @@ public static class Constants /// /// Represents the shared directory in the package. /// - public static readonly string SharedDirectory = "shared"; + public static readonly string ContentFilesDirectory = "contentFiles"; public static readonly string BinDirectory = "bin"; public static readonly string SettingsFileName = "NuGet.Config"; From 43b80019c79f482cb5a0b1c97e187466b9969b9a Mon Sep 17 00:00:00 2001 From: tom-englert Date: Fri, 16 Oct 2015 17:07:06 +0200 Subject: [PATCH 09/13] Add missing source files referenced by PDB. --- src/CommandLine/CommandLine.csproj | 408 +++++++++++---------- src/CommandLine/Commands/PdbHelper.cs | 256 +++++++++++++ src/CommandLine/Commands/ProjectFactory.cs | 58 +++ src/CommandLine/Project.json | 17 + 4 files changed, 543 insertions(+), 196 deletions(-) create mode 100644 src/CommandLine/Commands/PdbHelper.cs create mode 100644 src/CommandLine/Project.json diff --git a/src/CommandLine/CommandLine.csproj b/src/CommandLine/CommandLine.csproj index 9deac8729..ccfe2a87d 100644 --- a/src/CommandLine/CommandLine.csproj +++ b/src/CommandLine/CommandLine.csproj @@ -1,202 +1,218 @@ - - - - ..\..\NuGet.ruleset - true - - - x86 - true - false - bin\Debug\ - DEBUG;TRACE - - - x86 - pdbonly - true - bin\Release\ - - - - {B34A6632-E627-4B66-8E0A-D2DA3BC96893} - Exe - Properties - NuGet - NuGet - - - - - - - - False - ..\..\lib\Microsoft.Web.XmlTransform.dll - - - - - - - - - - - - Common\MsBuildProjectUtility.cs - - - - - - - - - True - True - HelpCommandMarkdownTemplate.cshtml - - - - - - - - - - - - - - - - - - - - - - - - - Common\NuGetConstants.cs - - - - - Properties\CommonAssemblyInfo.cs - - - - - - - - - - - - - - - - - - NuGetCommand.resx - - - - - True - True - NuGetResources.resx - - - - - - - - - - - Common\CommonResources.cs - - - - - - Properties\CodeAnalysisDictionary.xml - Designer - - - - - {F879F274-EFA0-4157-8404-33A19B4E6AEC} - Core - - - - - Common\CommonResources.resx - CommonResources.cs - Designer - - - Designer - - - ResXFileCodeGenerator - NuGetResources.Designer.cs - Designer - - - - - - - - Code - RazorGenerator - HelpCommandMarkdownTemplate.cs - - - - - - $(MsBuildProjectDirectory)\..\.. - $(NuGetRoot)\Tools\ILMerge\ILMerge.exe - $(NuGetRoot)\Build\ilmerge.internalize.ignore.txt - NuGet.exe - $(OutputPath)Merged\$(ILMergeOutputFile) - $(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" /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 - - - - - - - - - - - - - - - - - + + + + ..\..\NuGet.ruleset + true + $(UserProfile)\.nuget\packages + + + x86 + true + false + bin\Debug\ + DEBUG;TRACE + + + x86 + pdbonly + true + bin\Release\ + + + + {B34A6632-E627-4B66-8E0A-D2DA3BC96893} + Exe + Properties + NuGet + NuGet + + + + + + + + $(NuGetPackageRoot)\Microsoft.DiaSymReader\1.0.5.1\lib\portable-net45+win8\Microsoft.DiaSymReader.dll + + + False + ..\..\lib\Microsoft.Web.XmlTransform.dll + + + + + + + + + + + + Common\MsBuildProjectUtility.cs + + + + + + + + + True + True + HelpCommandMarkdownTemplate.cshtml + + + + + + + + + + + + + + + + + + + + + + + + + + Common\NuGetConstants.cs + + + + + Properties\CommonAssemblyInfo.cs + + + + + + + + + + + + + + + + + + NuGetCommand.resx + + + + + True + True + NuGetResources.resx + + + + + + + + + + + Common\CommonResources.cs + + + + + + PreserveNewest + false + + + PreserveNewest + false + + + + + Properties\CodeAnalysisDictionary.xml + Designer + + + + + {F879F274-EFA0-4157-8404-33A19B4E6AEC} + Core + + + + + Common\CommonResources.resx + CommonResources.cs + Designer + + + Designer + + + ResXFileCodeGenerator + NuGetResources.Designer.cs + Designer + + + + + + + + + Code + RazorGenerator + HelpCommandMarkdownTemplate.cs + + + + + + $(MsBuildProjectDirectory)\..\.. + $(NuGetRoot)\Tools\ILMerge\ILMerge.exe + $(NuGetRoot)\Build\ilmerge.internalize.ignore.txt + NuGet.exe + $(OutputPath)Merged\$(ILMergeOutputFile) + $(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" /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 + + + + + + + + + + + + + + + + + - + --> + \ No newline at end of file diff --git a/src/CommandLine/Commands/PdbHelper.cs b/src/CommandLine/Commands/PdbHelper.cs new file mode 100644 index 000000000..0b73a2964 --- /dev/null +++ b/src/CommandLine/Commands/PdbHelper.cs @@ -0,0 +1,256 @@ +namespace NuGet.Commands +{ + using System; + using System.Collections.Generic; + using System.Diagnostics; + using System.IO; + using System.Linq; + using System.Runtime.InteropServices; + using System.Runtime.InteropServices.ComTypes; + using System.Threading; + + using Microsoft.DiaSymReader; + + using STATSTG = System.Runtime.InteropServices.ComTypes.STATSTG; + + internal static class PdbHelper + { + public static IEnumerable GetSourceFileNames(IPackageFile pdbFile) + { + using (var stream = new StreamAdapter(pdbFile.GetStream())) + { + var reader = SymReaderFactory.CreateNativeSymReader(stream); + + return reader.GetDocuments() + .Select(doc => doc.GetName()) + .Where(IsValidSourceFileName); + } + } + + private static bool IsValidSourceFileName(string sourceFileName) + { + return !string.IsNullOrEmpty(sourceFileName) && !IsTemporaryCompilerFile(sourceFileName); + } + + private static bool IsTemporaryCompilerFile(string sourceFileName) + { + //the VB compiler will include temporary files in its pdb files. + //the source file name will be similar to 17d14f5c-a337-4978-8281-53493378c1071.vb. + return sourceFileName.EndsWith("17d14f5c-a337-4978-8281-53493378c1071.vb", StringComparison.InvariantCultureIgnoreCase); + } + + private static class SymReaderFactory + { + [DefaultDllImportSearchPaths(DllImportSearchPath.AssemblyDirectory)] + [DllImport("Microsoft.DiaSymReader.Native.x86.dll", EntryPoint = "CreateSymReader")] + private extern static void CreateSymReader32(ref Guid id, [MarshalAs(UnmanagedType.IUnknown)]out object symReader); + + [DefaultDllImportSearchPaths(DllImportSearchPath.AssemblyDirectory)] + [DllImport("Microsoft.DiaSymReader.Native.amd64.dll", EntryPoint = "CreateSymReader")] + private extern static void CreateSymReader64(ref Guid id, [MarshalAs(UnmanagedType.IUnknown)]out object symReader); + + internal static ISymUnmanagedReader3 CreateNativeSymReader(IStream pdbStream) + { + object symReader = null; + var guid = default(Guid); + + if (IntPtr.Size == 4) + { + CreateSymReader32(ref guid, out symReader); + } + else + { + CreateSymReader64(ref guid, out symReader); + } + + var reader = (ISymUnmanagedReader3)symReader; + var hr = reader.Initialize(new DummyMetadataImport(), null, null, pdbStream); + Marshal.ThrowExceptionForHR(hr); + return reader; + } + + class DummyMetadataImport : IMetadataImport { } + } + + /// + /// Wrap a Stream so it's usable where we need an IStream + /// + sealed class StreamAdapter : IStream, IDisposable + { + Stream _stream; + IntPtr _pcbData = Marshal.AllocHGlobal(8); // enough to store long/int64, can be shared since we don't support multithreaded access to one file. + + /// + /// Create a new adapter around the given stream. + /// + /// The stream to wrap. + public StreamAdapter(Stream wrappedStream) + { + _stream = wrappedStream; + } + + ~StreamAdapter() + { + throw new InvalidOperationException("Stream adapter not disposed"); + } + + public void Clone(out IStream ppstm) + { + throw new NotSupportedException(); + } + + public void Commit(int grfCommitFlags) + { + } + + public void LockRegion(long libOffset, long cb, int dwLockType) + { + throw new NotSupportedException(); + } + + public void Revert() + { + throw new NotSupportedException(); + } + + public void UnlockRegion(long libOffset, long cb, int dwLockType) + { + throw new NotSupportedException(); + } + + public void CopyTo(IStream pstm, long cb, IntPtr pcbRead, IntPtr pcbWritten) + { + throw new NotSupportedException(); + } + + public void Read(byte[] pv, int cb, IntPtr pcbRead) + { + var count = _stream.Read(pv, 0, cb); + if (pcbRead != IntPtr.Zero) + { + Marshal.WriteInt32(pcbRead, count); + } + } + + public void Seek(long dlibMove, int dwOrigin, IntPtr plibNewPosition) + { + var origin = (SeekOrigin)dwOrigin; + var pos = _stream.Seek(dlibMove, origin); + if (plibNewPosition != IntPtr.Zero) + { + Marshal.WriteInt64(plibNewPosition, pos); + } + } + + public void SetSize(long libNewSize) + { + _stream.SetLength(libNewSize); + } + + public void Stat(out STATSTG pstatstg, int grfStatFlag) + { + pstatstg = new STATSTG + { + type = 2, + cbSize = _stream.Length, + grfMode = 0 + }; + + if (_stream.CanRead && _stream.CanWrite) + { + pstatstg.grfMode |= 2; + } + else if (_stream.CanWrite && !_stream.CanRead) + { + pstatstg.grfMode |= 1; + } + } + + public void Write(byte[] pv, int cb, IntPtr pcbWritten) + { + _stream.Write(pv, 0, cb); + if (pcbWritten != IntPtr.Zero) + { + Marshal.WriteInt32(pcbWritten, cb); + } + } + + public void Dispose() + { + Interlocked.Exchange(ref _stream, null)?.Close(); + + var data = Interlocked.Exchange(ref _pcbData, IntPtr.Zero); + if (data != IntPtr.Zero) + { + Marshal.FreeHGlobal(_pcbData); + } + + GC.SuppressFinalize(this); + } + } + } + + [ComImport, Guid("7DAC8207-D3AE-4c75-9B67-92801A497D44"), InterfaceType(ComInterfaceType.InterfaceIsIUnknown), TypeIdentifier] + public interface IMetadataImport { } + + static class SymUnmanagedReaderExtensions + { + // Excerpt of http://source.roslyn.io/#Roslyn.Test.PdbUtilities/Shared/SymUnmanagedReaderExtensions.cs + + private const int E_FAIL = unchecked((int)0x80004005); + private const int E_NOTIMPL = unchecked((int)0x80004001); + + private delegate int ItemsGetter(TEntity entity, int bufferLength, out int count, TItem[] buffer); + + private static string ToString(char[] buffer) + { + Debug.Assert(buffer[buffer.Length - 1] == 0); + return new string(buffer, 0, buffer.Length - 1); + } + + private static void ValidateItems(int actualCount, int bufferLength) + { + if (actualCount != bufferLength) + { + throw new InvalidOperationException(string.Format("Read only {0} of {1} items.", actualCount, bufferLength)); + } + } + + private static TItem[] GetItems(TEntity entity, ItemsGetter getter) + { + int count; + var hr = getter(entity, 0, out count, null); + ThrowExceptionForHR(hr); + if (count == 0) + { + return null; + } + + var result = new TItem[count]; + hr = getter(entity, count, out count, result); + ThrowExceptionForHR(hr); + ValidateItems(count, result.Length); + return result; + } + + public static ISymUnmanagedDocument[] GetDocuments(this ISymUnmanagedReader reader) + { + return GetItems(reader, (ISymUnmanagedReader a, int b, out int c, ISymUnmanagedDocument[] d) => a.GetDocuments(b, out c, d)); + } + + internal static string GetName(this ISymUnmanagedDocument document) + { + return ToString(GetItems(document, (ISymUnmanagedDocument a, int b, out int c, char[] d) => a.GetUrl(b, out c, d))); + } + + internal static void ThrowExceptionForHR(int hr) + { + // E_FAIL indicates "no info". + // E_NOTIMPL indicates a lack of ISymUnmanagedReader support (in a particular implementation). + if (hr < 0 && hr != E_FAIL && hr != E_NOTIMPL) + { + Marshal.ThrowExceptionForHR(hr, new IntPtr(-1)); + } + } + } +} \ No newline at end of file diff --git a/src/CommandLine/Commands/ProjectFactory.cs b/src/CommandLine/Commands/ProjectFactory.cs index f6dbcbcda..a84ba0a8c 100644 --- a/src/CommandLine/Commands/ProjectFactory.cs +++ b/src/CommandLine/Commands/ProjectFactory.cs @@ -173,6 +173,11 @@ public PackageBuilder CreateBuilder(string basePath) ProcessDependencies(builder); + if (IncludeSymbols) + { + AddMissingSourceFilesReferencedByPdb(builder); + } + // Set defaults if some required fields are missing if (String.IsNullOrEmpty(builder.Description)) { @@ -1093,5 +1098,58 @@ IEnumerable IFrameworkTargetable.SupportedFrameworks } } } + + private void AddMissingSourceFilesReferencedByPdb(PackageBuilder builder) + { + // We build a new symbol package from physical files, so it's safe to cast here (we need the SourcePath property). + var packageFiles = builder.Files.OfType().ToArray(); + + var pdbFiles = packageFiles.Where(file => file.Path.EndsWith(".pdb", StringComparison.OrdinalIgnoreCase)); + var missingFiles = pdbFiles.SelectMany(pdbFile => GetMissingSourceFilesReferencedByPdb(pdbFile, packageFiles)); + + foreach (var file in missingFiles) + { + AddFileToBuilder(builder, file); + } + } + + private IEnumerable GetMissingSourceFilesReferencedByPdb(IPackageFile pdbFile, IEnumerable packageFiles) + { + try + { + var sourceFiles = PdbHelper.GetSourceFileNames(pdbFile); + var missingFiles = sourceFiles.Except(packageFiles.Select(file => file.SourcePath), StringComparer.OrdinalIgnoreCase); + + return missingFiles.Select(CreatePackageFileFromSourceFile).Where(file => file != null); + } + catch + { + // Not a pdb file or file is corrupt. + } + + return Enumerable.Empty(); + } + + private PhysicalPackageFile CreatePackageFileFromSourceFile(string file) + { + var targetFilePath = Normalize(file); + + if (!File.Exists(file)) + { + Logger.Log(MessageLevel.Warning, LocalizedResourceManager.GetString("Warning_FileDoesNotExist"), targetFilePath); + return null; + } + + var projectName = Path.GetFileNameWithoutExtension(_project.FullPath); + + // if IncludeReferencedProjects is true and we are adding source files, + // add projectName as part of the target to avoid file conflicts. + var targetPath = IncludeReferencedProjects + ? Path.Combine(SourcesFolder, projectName, targetFilePath) + : Path.Combine(SourcesFolder, targetFilePath); + + return new PhysicalPackageFile { SourcePath = file, TargetPath = targetPath }; + } } } + diff --git a/src/CommandLine/Project.json b/src/CommandLine/Project.json new file mode 100644 index 000000000..ed10b7838 --- /dev/null +++ b/src/CommandLine/Project.json @@ -0,0 +1,17 @@ +{ + "dependencies": { + "Microsoft.DiaSymReader.Native": "1.1.0-alpha2", + "Microsoft.DiaSymReader": "1.0.5.1" + }, + + "frameworks": { + "net45": { } + }, + + "runtimes": { + "win7-x86": { }, + "win7-x64": { }, + "win8-x86": { }, + "win8-x64": { } + } +} \ No newline at end of file From a6300b9e73982eccd9ea1b60bd97d3b8eaea68e8 Mon Sep 17 00:00:00 2001 From: tom-englert Date: Sat, 17 Oct 2015 09:58:45 +0200 Subject: [PATCH 10/13] Update DiaSymReader packages --- src/CommandLine/CommandLine.csproj | 6 +++--- src/CommandLine/Project.json | 4 ++-- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/src/CommandLine/CommandLine.csproj b/src/CommandLine/CommandLine.csproj index ccfe2a87d..c88906dde 100644 --- a/src/CommandLine/CommandLine.csproj +++ b/src/CommandLine/CommandLine.csproj @@ -32,7 +32,7 @@ - $(NuGetPackageRoot)\Microsoft.DiaSymReader\1.0.5.1\lib\portable-net45+win8\Microsoft.DiaSymReader.dll + $(NuGetPackageRoot)\Microsoft.DiaSymReader\1.0.6\lib\portable-net45+win8\Microsoft.DiaSymReader.dll False @@ -131,11 +131,11 @@ - + PreserveNewest false - + PreserveNewest false diff --git a/src/CommandLine/Project.json b/src/CommandLine/Project.json index ed10b7838..e5209253a 100644 --- a/src/CommandLine/Project.json +++ b/src/CommandLine/Project.json @@ -1,7 +1,7 @@ { "dependencies": { - "Microsoft.DiaSymReader.Native": "1.1.0-alpha2", - "Microsoft.DiaSymReader": "1.0.5.1" + "Microsoft.DiaSymReader.Native": "1.2.0-rc", + "Microsoft.DiaSymReader": "1.0.6" }, "frameworks": { From f4b67ad8b9813e5690a731e121c8fb7ea1bf0261 Mon Sep 17 00:00:00 2001 From: tom-englert Date: Sat, 17 Oct 2015 10:07:23 +0200 Subject: [PATCH 11/13] Move PdbHelper to common folder --- src/CommandLine/CommandLine.csproj | 2 +- src/CommandLine/{Commands => Common}/PdbHelper.cs | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) rename src/CommandLine/{Commands => Common}/PdbHelper.cs (96%) diff --git a/src/CommandLine/CommandLine.csproj b/src/CommandLine/CommandLine.csproj index c88906dde..41f970dc6 100644 --- a/src/CommandLine/CommandLine.csproj +++ b/src/CommandLine/CommandLine.csproj @@ -62,7 +62,7 @@ HelpCommandMarkdownTemplate.cshtml - + diff --git a/src/CommandLine/Commands/PdbHelper.cs b/src/CommandLine/Common/PdbHelper.cs similarity index 96% rename from src/CommandLine/Commands/PdbHelper.cs rename to src/CommandLine/Common/PdbHelper.cs index 0b73a2964..27db44e21 100644 --- a/src/CommandLine/Commands/PdbHelper.cs +++ b/src/CommandLine/Common/PdbHelper.cs @@ -1,4 +1,4 @@ -namespace NuGet.Commands +namespace NuGet.Common { using System; using System.Collections.Generic; From 5e38916970eed0f0df66127670162f5dc03d3669 Mon Sep 17 00:00:00 2001 From: tom-englert Date: Sat, 17 Oct 2015 10:17:45 +0200 Subject: [PATCH 12/13] Add log output for errors --- src/CommandLine/Commands/ProjectFactory.cs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/CommandLine/Commands/ProjectFactory.cs b/src/CommandLine/Commands/ProjectFactory.cs index a84ba0a8c..08c60d6b8 100644 --- a/src/CommandLine/Commands/ProjectFactory.cs +++ b/src/CommandLine/Commands/ProjectFactory.cs @@ -1122,9 +1122,9 @@ private IEnumerable GetMissingSourceFilesReferencedByPdb(IP return missingFiles.Select(CreatePackageFileFromSourceFile).Where(file => file != null); } - catch + catch (Exception ex) { - // Not a pdb file or file is corrupt. + _logger.Log(MessageLevel.Warning, "{0} seems to be not a valid pdb file ({1})", pdbFile.Path, ex.Message); } return Enumerable.Empty(); From 7c84c46d2296f65a3b601c3c7e8106b509eade42 Mon Sep 17 00:00:00 2001 From: tom-englert Date: Sat, 17 Oct 2015 10:27:46 +0200 Subject: [PATCH 13/13] Fix possible null refs --- src/CommandLine/Common/PdbHelper.cs | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/src/CommandLine/Common/PdbHelper.cs b/src/CommandLine/Common/PdbHelper.cs index 27db44e21..e4f072c50 100644 --- a/src/CommandLine/Common/PdbHelper.cs +++ b/src/CommandLine/Common/PdbHelper.cs @@ -204,6 +204,9 @@ static class SymUnmanagedReaderExtensions private static string ToString(char[] buffer) { + if (buffer.Length == 0) + return string.Empty; + Debug.Assert(buffer[buffer.Length - 1] == 0); return new string(buffer, 0, buffer.Length - 1); } @@ -222,9 +225,7 @@ private static TItem[] GetItems(TEntity entity, ItemsGetter