From 2daec6f1bc4696f402942e8a23dd5ba729ba0685 Mon Sep 17 00:00:00 2001 From: dannyvarod_cp Date: Tue, 28 Oct 2014 17:57:02 +0000 Subject: [PATCH] v2.5.0 Enabled including non-project references (e.g. 3rd party libraries under lib), Added Demo.Readme.txt for explaining demo of the various features git-tfs-id: [https://tfs.codeplex.com/tfs/tfs27]$/pubcomp/Building;C29166 --- Building.sln | 23 ++- Demo.Binary1/Demo.Binary1.csproj | 56 ++++++ Demo.Binary1/Demo.Binary1.csproj.vspscc | 10 + Demo.Binary1/Properties/AssemblyInfo.cs | 36 ++++ .../Demo.Package1.NuGet.csproj | 6 + Demo.Readme.txt | 27 +++ .../PubComp.Building.Demo.Binary1.dll | Bin 0 -> 4096 bytes .../PubComp.Building.Demo.Binary1.pdb | Bin 0 -> 7680 bytes NuGetPack.UnitTests/NuGetPackTests.cs | 54 +++++- NuGetPack/ElementType.cs | 1 - NuGetPack/NuspecCreator.cs | 175 ++++++++---------- VersionHistory.txt | 33 +++- VersionInfo.cs | 4 +- 13 files changed, 307 insertions(+), 118 deletions(-) create mode 100644 Demo.Binary1/Demo.Binary1.csproj create mode 100644 Demo.Binary1/Demo.Binary1.csproj.vspscc create mode 100644 Demo.Binary1/Properties/AssemblyInfo.cs create mode 100644 Demo.Readme.txt create mode 100644 Dependencies/PubComp.Building.Demo.Binary1.dll create mode 100644 Dependencies/PubComp.Building.Demo.Binary1.pdb diff --git a/Building.sln b/Building.sln index 5e67be9..1d5d41d 100644 --- a/Building.sln +++ b/Building.sln @@ -11,6 +11,7 @@ Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Solution Items", "Solution ProjectSection(SolutionItems) = preProject .tfignore = .tfignore Data.txt = Data.txt + Demo.Readme.txt = Demo.Readme.txt DemoVersionInfo.cs = DemoVersionInfo.cs VersionHistory.txt = VersionHistory.txt VersionInfo.cs = VersionInfo.cs @@ -37,9 +38,17 @@ Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Demo.Package2.NuGet", "Demo EndProject Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Tests", "Tests", "{92F43E67-AED8-4353-B2F9-61138C5AAFC4}" EndProject +Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Demo.Binary1", "Demo.Binary1\Demo.Binary1.csproj", "{390AB87B-8AB1-45E7-A444-04EACB7F7F69}" +EndProject +Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Dependencies", "Dependencies", "{8B8778A0-C4F1-4564-A99D-CFEF3517F45C}" + ProjectSection(SolutionItems) = preProject + Dependencies\PubComp.Building.Demo.Binary1.dll = Dependencies\PubComp.Building.Demo.Binary1.dll + Dependencies\PubComp.Building.Demo.Binary1.pdb = Dependencies\PubComp.Building.Demo.Binary1.pdb + EndProjectSection +EndProject Global GlobalSection(TeamFoundationVersionControl) = preSolution - SccNumberOfProjects = 8 + SccNumberOfProjects = 9 SccEnterpriseProvider = {4CA58AB2-18FA-4F8D-95D4-32DDF27D184C} SccTeamFoundationServer = https://tfs.codeplex.com/tfs/tfs27 SccLocalPath0 = . @@ -70,6 +79,10 @@ Global SccProjectTopLevelParentUniqueName7 = Building.sln SccProjectName7 = Demo.Package2.NuGet SccLocalPath7 = Demo.Package2.NuGet + SccProjectUniqueName8 = Demo.Binary1\\Demo.Binary1.csproj + SccProjectTopLevelParentUniqueName8 = Building.sln + SccProjectName8 = Demo.Binary1 + SccLocalPath8 = Demo.Binary1 EndGlobalSection GlobalSection(SolutionConfigurationPlatforms) = preSolution Debug|Any CPU = Debug|Any CPU @@ -104,16 +117,22 @@ Global {86666499-C05D-4B93-B955-08196EFA737D}.Debug|Any CPU.Build.0 = Debug|Any CPU {86666499-C05D-4B93-B955-08196EFA737D}.Release|Any CPU.ActiveCfg = Release|Any CPU {86666499-C05D-4B93-B955-08196EFA737D}.Release|Any CPU.Build.0 = Release|Any CPU + {390AB87B-8AB1-45E7-A444-04EACB7F7F69}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {390AB87B-8AB1-45E7-A444-04EACB7F7F69}.Debug|Any CPU.Build.0 = Debug|Any CPU + {390AB87B-8AB1-45E7-A444-04EACB7F7F69}.Release|Any CPU.ActiveCfg = Release|Any CPU + {390AB87B-8AB1-45E7-A444-04EACB7F7F69}.Release|Any CPU.Build.0 = Release|Any CPU EndGlobalSection GlobalSection(SolutionProperties) = preSolution HideSolutionNode = FALSE EndGlobalSection GlobalSection(NestedProjects) = preSolution + {EBDA70BF-FAAD-4E23-B8D4-79299D049755} = {92F43E67-AED8-4353-B2F9-61138C5AAFC4} + {8B8778A0-C4F1-4564-A99D-CFEF3517F45C} = {47B3A300-8E8D-44FD-8391-657BD15F3E49} {B0F71956-487C-47BD-84B5-C0CF9F423A12} = {D2BDB301-DA26-4025-ADC2-2AFBD077B93E} {8E1E32DE-D870-4681-8C43-9E725FC4481A} = {D2BDB301-DA26-4025-ADC2-2AFBD077B93E} {6B73E931-E155-4F8E-ADEF-83E8E7BB53E4} = {D2BDB301-DA26-4025-ADC2-2AFBD077B93E} {7812FFE0-3D9D-4B93-89F8-770C7B0E92D8} = {D2BDB301-DA26-4025-ADC2-2AFBD077B93E} {86666499-C05D-4B93-B955-08196EFA737D} = {D2BDB301-DA26-4025-ADC2-2AFBD077B93E} - {EBDA70BF-FAAD-4E23-B8D4-79299D049755} = {92F43E67-AED8-4353-B2F9-61138C5AAFC4} + {390AB87B-8AB1-45E7-A444-04EACB7F7F69} = {D2BDB301-DA26-4025-ADC2-2AFBD077B93E} EndGlobalSection EndGlobal diff --git a/Demo.Binary1/Demo.Binary1.csproj b/Demo.Binary1/Demo.Binary1.csproj new file mode 100644 index 0000000..94d2909 --- /dev/null +++ b/Demo.Binary1/Demo.Binary1.csproj @@ -0,0 +1,56 @@ + + + + + Debug + AnyCPU + {390AB87B-8AB1-45E7-A444-04EACB7F7F69} + Library + Properties + PubComp.Building.Demo.Binary1 + PubComp.Building.Demo.Binary1 + v4.5 + 512 + SAK + SAK + SAK + SAK + + + 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/Demo.Binary1/Demo.Binary1.csproj.vspscc b/Demo.Binary1/Demo.Binary1.csproj.vspscc new file mode 100644 index 0000000..feffdec --- /dev/null +++ b/Demo.Binary1/Demo.Binary1.csproj.vspscc @@ -0,0 +1,10 @@ +"" +{ +"FILE_VERSION" = "9237" +"ENLISTMENT_CHOICE" = "NEVER" +"PROJECT_FILE_RELATIVE_PATH" = "" +"NUMBER_OF_EXCLUDED_FILES" = "0" +"ORIGINAL_PROJECT_FILE_PATH" = "" +"NUMBER_OF_NESTED_PROJECTS" = "0" +"SOURCE_CONTROL_SETTINGS_PROVIDER" = "PROVIDER" +} diff --git a/Demo.Binary1/Properties/AssemblyInfo.cs b/Demo.Binary1/Properties/AssemblyInfo.cs new file mode 100644 index 0000000..9d602cb --- /dev/null +++ b/Demo.Binary1/Properties/AssemblyInfo.cs @@ -0,0 +1,36 @@ +using System.Reflection; +using System.Runtime.CompilerServices; +using System.Runtime.InteropServices; + +// General Information about an assembly is controlled through the following +// set of attributes. Change these attribute values to modify the information +// associated with an assembly. +[assembly: AssemblyTitle("Demo.Binary1")] +[assembly: AssemblyDescription("")] +[assembly: AssemblyConfiguration("")] +[assembly: AssemblyCompany("")] +[assembly: AssemblyProduct("Demo.Binary1")] +[assembly: AssemblyCopyright("Copyright © 2014")] +[assembly: AssemblyTrademark("")] +[assembly: AssemblyCulture("")] + +// Setting ComVisible to false makes the types in this assembly not visible +// to COM components. If you need to access a type in this assembly from +// COM, set the ComVisible attribute to true on that type. +[assembly: ComVisible(false)] + +// The following GUID is for the ID of the typelib if this project is exposed to COM +[assembly: Guid("6065e8b8-6ea0-456d-b4ac-0d4af2e2cd50")] + +// Version information for an assembly consists of the following four values: +// +// Major Version +// Minor Version +// Build Number +// Revision +// +// You can specify all the values or you can default the Build and Revision Numbers +// by using the '*' as shown below: +// [assembly: AssemblyVersion("1.0.*")] +[assembly: AssemblyVersion("1.0.0.0")] +[assembly: AssemblyFileVersion("1.0.0.0")] diff --git a/Demo.Package1.NuGet/Demo.Package1.NuGet.csproj b/Demo.Package1.NuGet/Demo.Package1.NuGet.csproj index 051d507..64b9a90 100644 --- a/Demo.Package1.NuGet/Demo.Package1.NuGet.csproj +++ b/Demo.Package1.NuGet/Demo.Package1.NuGet.csproj @@ -52,6 +52,12 @@ content\Data.txt + + lib\PubComp.Building.Demo.Binary1.dll + + + lib\PubComp.Building.Demo.Binary1.pdb + diff --git a/Demo.Readme.txt b/Demo.Readme.txt new file mode 100644 index 0000000..b02fbcd --- /dev/null +++ b/Demo.Readme.txt @@ -0,0 +1,27 @@ +Demo.Library1, Demo.Library2, Demo.Library3: +* are examples of projects in the solution that we want to include in NuGet packages +* get their version number from DemoVersionInfo.cs which is shared with Demo.Library1, Demo.Library2, Demo.Library3 + +Demo.Package1.NuGet, Demo.Package2.NuGet: +* are examples of NuGet projects, for creating a NuGet package +* are based on the standard Class Library template +* to create packages automatically during build, add the following post-build event command line to your NuGet projects: + "$(SolutionDir)NuGetPack.exe" "$(ProjectPath)" "$(TargetPath)" $(ConfigurationName) + (Copy NuGetPack.exe to your solution folder and place it under Solution Items to have it added to your source control) + +Demo.Package1: +* a NuGet package created by NuGet project Demo.Package1.NuGet +* will include Demo.Library1, Demo.Library2 (via project references) and their external NuGet dependencies (total 6 dependencies) +* gets its version number from DemoVersionInfo.cs which is shared with Demo.Library1, Demo.Library2, Demo.Library3 +* gets its metadata from its AssemblyInfo.cs +* includes content via content folder (both files and linked files in example) +* includes a "3rd party" non-NuGet .NET assembly (Demo.Binary1) via lib folder (linked files in example) + +Demo.Package2: +* a NuGet package created by NuGet project Demo.Package2.NuGet +* will include Demo.Library3 (via project reference) and its external NuGet dependencies (none) +* includes direct external NuGet dependencies via its own packages.config +* includes an internal NuGet dependency (Demo.Package1) via its own internalPackages.config +* gets its version number from DemoVersionInfo.cs which is shared with Demo.Library1, Demo.Library2, Demo.Library3 +* gets its metadata from its NuGetPack.config +* includes framework reference System.Xaml (option is set on via NuGetPack.config) diff --git a/Dependencies/PubComp.Building.Demo.Binary1.dll b/Dependencies/PubComp.Building.Demo.Binary1.dll new file mode 100644 index 0000000000000000000000000000000000000000..0bc97f4b19a1c224d540c3c2dd94cf2b7b0033b2 GIT binary patch literal 4096 zcmeHKO>7%Q6n^XcG;P|@l&a8D(G6)S70t>{oY2z0Bz9U{rHP4M^HZZ_*Pb}ru6NDu zx{Zref}nz)Kxz>jKtkfw3j(Q#3W*CGkU%}b71R@4P(d6(0*UgyS=({qv`7e~BJte$ zX6DU%Z@!r~nb{tD`Za1HqE?ifH;JyIW*L@vdsx75*S3$l=*sGAJy(_SYdz^X(^E^X zQ*ia7n$vCD@l`{pZrN5%Ta8bq)S{CY+PZaXwpT+Z$B4$27P|b!WV$xnbqe)#DxE|f z(6k5Ib30M1D8nd3>t#C>@McBTjA#KJ=vi85<~*D7zs0)RWfkNh#7%Kym}rhSV!6x^ zt%dHV9YkA~kKL}X2J~wt9q2z+>!8+rG4G>(X%#?4;k8zIqa{Tpn$cX(&7mi`4Wq${ zT7%Lc!(gwu!g659TxkY{V|Af4$S~1pLsvFucwZsREktdUREgecBT`uTH)J$*bX2K& zGndm*EvyZM2O@hpSQ}ZuO95Id#29jwj-% z-{dj&9km<-eHOSYt2Pp?=FV?B253{jy&GL#1N-wfaGMKnUQoBwBn{%+ERYR+L*f;Q zUrGEyVw=LFs>FQ~JteKQ)5{WHmzwt^eye<`?4zF%yq$VNN~oPifIMR`AMeU)n#26v z5;sfik+@4@MB-kFBN7u59|zt=Psz3}(UkZsa3j3{+(H+C+eo8M>IL3SMc{q(Jg`^d z!x9IiejlBOJ|;COi6`i7Xim}RK##r#K1bgGU!?D-b)mKbEJeyRR)tj5MWNmGHtj#= zzR%XA4=Clz{N{m}Q>wUTVQz(?w5#VuQEyyQjbp5A z`DM3({Icyy*uHR`QcAd|&7ANEyPPpS(`a1pk+PX@=2P9+=7GbeC7K4S)5cA`U^|{~ z<~)iEqg*KHOQs5RNEQ+gHp|HJ5kPRaku4N*i>HL8&&!s#NU3@V*bhU7X_r;P(5fm*7elBG(0zcL9q>{T3T@FQ z#?tlEw!69|2XKiEDwOWpSRaa;Udhrc6F8R}*hj68sIcu;Xl>(Z$Hgb_fO{0$P(Ksu zr@oKA4GBHm7abhR_Zd+=*B8!5_1S*WpUV%1alI?FDuNpo zKY16*`-Lw>zB7sL=SwCX+Vq60mnIy0Y(6LCSx?Wo&KWPbhp7J6vh!9b*FK1X08^=W z>idf)4jsI4^ytM)zx?{yhtFi#C--PJK9US14?;=N&hD#S$!v&tj%qeTg_5?PZvj~V~!iQtYf-q2REJ&^7dnkn>!GPpQt-T z6iMb@Ji|)~1ur^|T$7&d_}k&hVZ5~s-%smXaIPtXZ>wqG7)_y-z>7P9egb$HZI(}3 zfBYkOU-+c41ofeyBj1_ekXIF`;?gQZI=P5r;+sMsrcJZtNTco2D~(YdS`Xto`LJ`) z3*`OQ5`rq=GwB=|P_EE2 zVC7bQznJ+y$9ccZMG|v4SVtLo@Edl8bG7oSK@(g#2TOgIXJUCC_DG)*iNhc2h9dGce%gl5z=V00Jg3V&Dfd13-Kr;Db=3m16=>45YXj{{LqI(##D&ViXMP5Wp7yJfrbHtm7Qn zb5ryT8CRb24`BofKA#+IZ}-m2Yx0zD-w$t%4TGrz$$>C3aGYp_E`%&S${r#ifGz)n zYDMJoAH)ZF2b~@wUL18Mo)8#~e>{OR0;K-E|MwnVzK@pZBOu06y$CAPr8xCJqKc04 zMoI{P;=i2JkP(#iIT#qaIT?N(<6?N>4)Q;!4FJO+J`6~L8Sf5&DBWFp@U$~pmVg6h zND-iJKQ1s@HsA`G;UkW(|EC1>roK;RUbbgmT0Vn*USe))F@t__QL=tUYGO)iQBqER zayA1qP!$^xgGvx7AO-kS4@AO@K=3Win)@D45Kj=Gl0Apiijq;)6& literal 0 HcmV?d00001 diff --git a/NuGetPack.UnitTests/NuGetPackTests.cs b/NuGetPack.UnitTests/NuGetPackTests.cs index 4156306..8b38fa5 100644 --- a/NuGetPack.UnitTests/NuGetPackTests.cs +++ b/NuGetPack.UnitTests/NuGetPackTests.cs @@ -204,8 +204,10 @@ public void TestGetDependenciesViaReferenceOuter2() #endregion + #region Package content (lib, content, ...) + [TestMethod] - public void TestGetContentFiles() + public void TestGetContentFiles1() { var creator = new NuspecCreator(); var results = creator.GetContentFiles( @@ -234,10 +236,55 @@ public void TestGetContentFiles() } [TestMethod] - public void TestGetBinaryFiles() + public void TestGetContentFiles2() + { + var creator = new NuspecCreator(); + var results = creator.GetContentFiles( + Path.GetDirectoryName(nuProj2Dll), @"..\..", nuProj2Csproj); + + LinqAssert.Count(results, 0); + } + + [TestMethod] + public void TestGetBinaryFiles1() { var creator = new NuspecCreator(); var results = creator.GetBinaryFiles( + Path.GetDirectoryName(nuProj1Dll), @"..\..", nuProj1Csproj); + + var path = isLocal ? @"..\..\..\Dependencies\" : @"..\..\Dependencies\"; + + LinqAssert.Count(results, 2); + var elements = results.Select(el => el.Element).ToList(); + + LinqAssert.Any(elements, el => + el.Name == "file" + && el.Attribute("src").Value == path + @"PubComp.Building.Demo.Binary1.dll" + && el.Attribute("target").Value == @"lib\net45\PubComp.Building.Demo.Binary1.dll", + "Found: " + results.First()); + + LinqAssert.Any(elements, el => + el.Name == "file" + && el.Attribute("src").Value == path + @"PubComp.Building.Demo.Binary1.pdb" + && el.Attribute("target").Value == @"lib\net45\PubComp.Building.Demo.Binary1.pdb", + "Found: " + results.First()); + } + + [TestMethod] + public void TestGetBinaryFiles2() + { + var creator = new NuspecCreator(); + var results = creator.GetBinaryFiles( + Path.GetDirectoryName(nuProj2Dll), @"..\..", nuProj2Csproj); + + LinqAssert.Count(results, 0); + } + + [TestMethod] + public void TestGetBinaryReferences() + { + var creator = new NuspecCreator(); + var results = creator.GetBinaryReferences( Path.GetDirectoryName(nuProj1Dll), @"..\..\..\Demo.Library3", proj3Csproj, isDebug, Path.GetDirectoryName(proj3Dll)); var path = isLocal ? @"..\..\..\Demo.Library3\bin\" : @"..\..\Demo.Library3\bin\"; @@ -332,7 +379,6 @@ public void TestGetFiles() Assert.AreNotEqual(0, results.Count()); var files = results.Where(el => el.ElementType != ElementType.NuGetDependency - && el.ElementType != ElementType.AssemblyReference && el.ElementType != ElementType.FrameworkReference) .ToList(); var elements = files.Select(el => el.Element).ToList(); @@ -340,6 +386,8 @@ public void TestGetFiles() LinqAssert.All(elements, r => File.Exists(Path.Combine(nuspecFolder, r.Attribute("src").Value))); } + #endregion + #region Create Ouput Tests [TestMethod] diff --git a/NuGetPack/ElementType.cs b/NuGetPack/ElementType.cs index 98a095c..460c60a 100644 --- a/NuGetPack/ElementType.cs +++ b/NuGetPack/ElementType.cs @@ -14,7 +14,6 @@ public enum ElementType ToolsFile, BuildFile, FrameworkReference, - AssemblyReference, NuGetDependency } } diff --git a/NuGetPack/NuspecCreator.cs b/NuGetPack/NuspecCreator.cs index 7ebb0ac..3a4904f 100644 --- a/NuGetPack/NuspecCreator.cs +++ b/NuGetPack/NuspecCreator.cs @@ -222,8 +222,7 @@ public XDocument CreateNuspec(string projectPath, string assemblyPath, bool isDe } var files = elements.Where(el => - el.ElementType != ElementType.AssemblyReference - && el.ElementType != ElementType.NuGetDependency + el.ElementType != ElementType.NuGetDependency && el.ElementType != ElementType.FrameworkReference) .Select(el => el.Element).ToList(); @@ -338,6 +337,7 @@ public IEnumerable GetElements(string nuspecFolder, string proje var result = new List(); result.AddRange(GetContentFiles(nuspecFolder, projectFolder, projectPath)); + result.AddRange(GetBinaryFiles(nuspecFolder, projectFolder, projectPath)); var references = GetReferences(nuspecFolder, projectPath, projectFolder); @@ -347,15 +347,15 @@ public IEnumerable GetElements(string nuspecFolder, string proje DebugOut(() => "refFolder = " + refFolder); - var projFolder = Path.Combine(projectFolder, refFolder); - var projPath = Path.Combine(projectFolder, reference); + var refProjFolder = Path.Combine(projectFolder, refFolder); + var refProjPath = Path.Combine(projectFolder, reference); - DebugOut(() => "projFolder = " + projFolder); - DebugOut(() => "projPath = " + projPath); + DebugOut(() => "projFolder = " + refProjFolder); + DebugOut(() => "projPath = " + refProjPath); - result.AddRange(GetBinaryFiles(nuspecFolder, projFolder, projPath, isDebug, nuspecFolder)); - result.AddRange(GetSourceFiles(nuspecFolder, projFolder, projPath)); - result.AddRange(GetDependenciesFromProject(projFolder, projPath)); + result.AddRange(GetBinaryReferences(nuspecFolder, refProjFolder, refProjPath, isDebug, nuspecFolder)); + result.AddRange(GetSourceFiles(nuspecFolder, refProjFolder, refProjPath)); + result.AddRange(GetDependenciesFromProject(refProjFolder, refProjPath)); } return result; @@ -363,7 +363,7 @@ public IEnumerable GetElements(string nuspecFolder, string proje public IEnumerable GetContentFiles(string nuspecFolder, string projectFolder, string projectPath) { - DebugOut(() => string.Format("\r\n\r\nGetContentFiles({0}, {1})\r\n", projectFolder, projectPath)); + DebugOut(() => string.Format("\r\n\r\nGetContentFiles({0}, {1}, {2})\r\n", nuspecFolder, projectFolder, projectPath)); var csProj = XDocument.Load(projectPath); @@ -394,6 +394,67 @@ public IEnumerable GetContentFiles(string nuspecFolder, string p return items; } + public IEnumerable GetFrameworkReferences(string projectFolder, string projectPath) + { + DebugOut(() => string.Format("\r\n\r\nGetFrameworkReferences({0}, {1})\r\n", projectFolder, projectPath)); + + var csProj = XDocument.Load(projectPath); + + var xmlns = csProj.Root.GetDefaultNamespace(); + var proj = csProj.Element(xmlns + "Project"); + + var referencedBinaryFiles = proj.Elements(xmlns + "ItemGroup") + .SelectMany(el => el.Elements(xmlns + "Reference")) + .Where(el => el.Attribute("Include") != null && !el.Elements(xmlns + "HintPath").Any()) + .Select(el => el.Attribute("Include").Value) + .ToList(); + + // + + var items = referencedBinaryFiles + .Select(el => + new DependencyInfo( + ElementType.FrameworkReference, + new XElement("frameworkAssembly", + new XAttribute("assemblyName", el)))) + .ToList(); + + return items; + } + + public IEnumerable GetBinaryFiles(string nuspecFolder, string projectFolder, string projectPath) + { + DebugOut(() => string.Format("\r\n\r\nGetAssemblyReferences({0}, {1}, {2})\r\n", nuspecFolder, projectFolder, projectPath)); + + var csProj = XDocument.Load(projectPath); + + var xmlns = csProj.Root.GetDefaultNamespace(); + var libElements = csProj.Element(xmlns + "Project").Elements(xmlns + "ItemGroup").Elements() + .Where(el => el.Attribute("Include") != null) + .Select(el => + new + { + src = el.Attribute("Include").Value, + target = el.Elements(xmlns + "Link").Any() + ? el.Elements(xmlns + "Link").First().Value + : el.Attribute("Include").Value + }) + .Where(st => st.target.ToLower().StartsWith(@"lib\")); + + var relativeProjectFolder = AbsolutePathToRelativePath(projectFolder, nuspecFolder + "\\"); + + var items = libElements + .Select(s => + new DependencyInfo( + ElementType.LibraryFile, + new XElement("file", + new XAttribute("src", Path.Combine(relativeProjectFolder, s.src)), + new XAttribute("target", Path.Combine(@"lib\net45\", Path.GetFileName(s.target)))))) + .ToList(); + + return items; + } + public string GetIcon(string nuspecFolder, string projectFolder, string projectPath) { var csProj = XDocument.Load(projectPath); @@ -445,10 +506,10 @@ private string GetOutputPath(XDocument csProj, bool isDebug, string projectFolde return outputPath; } - public IEnumerable GetBinaryFiles( + public IEnumerable GetBinaryReferences( string nuspecFolder, string projectFolder, string projectPath, bool isDebug, string buildMachineBinFolder) { - DebugOut(() => string.Format("\r\n\r\nGetBinaryFiles({0}, {1}, {2}, {3})\r\n", projectFolder, projectPath, isDebug, buildMachineBinFolder)); + DebugOut(() => string.Format("\r\n\r\nGetBinaryReferences({0}, {1}, {2}, {3})\r\n", projectFolder, projectPath, isDebug, buildMachineBinFolder)); string outputPath; @@ -560,95 +621,5 @@ public IEnumerable GetDependenciesFromProject(string projectFold return dependencies; } - - public IEnumerable GetFrameworkReferences(string projectFolder, string projectPath) - { - DebugOut(() => string.Format("\r\n\r\nGetFrameworkReferences({0}, {1})\r\n", projectFolder, projectPath)); - - var csProj = XDocument.Load(projectPath); - - var xmlns = csProj.Root.GetDefaultNamespace(); - var proj = csProj.Element(xmlns + "Project"); - - var referencedBinaryFiles = proj.Elements(xmlns + "ItemGroup") - .SelectMany(el => el.Elements(xmlns + "Reference")) - .Where(el => el.Attribute("Include") != null && !el.Elements(xmlns + "HintPath").Any()) - .Select(el => el.Attribute("Include").Value) - .ToList(); - - // - - var items = referencedBinaryFiles - .Select(el => - new DependencyInfo( - ElementType.FrameworkReference, - new XElement("frameworkAssembly", - new XAttribute("assemblyName", el)))) - .ToList(); - - return items; - } - - public IEnumerable GetAssemblyReferences( - string nuspecFolder, string projectFolder, string projectPath, bool isDebug) - { - DebugOut(() => string.Format("\r\n\r\nGetAssemblyReferences({0}, {1})\r\n", projectFolder, projectPath)); - - var csProj = XDocument.Load(projectPath); - var projectName = Path.GetFileNameWithoutExtension(projectPath); - - var outputPath = GetOutputPath(csProj, isDebug, projectFolder); - - var xmlns = csProj.Root.GetDefaultNamespace(); - var proj = csProj.Element(xmlns + "Project"); - - var referencedBinaryFiles = proj.Elements(xmlns + "ItemGroup") - .SelectMany(el => el.Elements(xmlns + "Reference")) - .SelectMany(el => el.Elements(xmlns + "HintPath")) - .Where(el => !el.Value.Contains(@"\packages\")) - .Select(el => Path.Combine(projectFolder, el.Value)) - .ToList(); - - var relativeOutputPath = AbsolutePathToRelativePath(outputPath, nuspecFolder + "\\"); - - var items = new List(); - - foreach (var file in referencedBinaryFiles) - { - items.Add( - new DependencyInfo( - ElementType.LibraryFile, - new XElement("file", - new XAttribute("src", Path.Combine(relativeOutputPath, Path.GetFileName(file))), - new XAttribute("target", Path.Combine(@"lib\net45\", Path.GetFileName(file))) - ))); - - var pdbFile = Path.ChangeExtension(file, ".pdb"); - if (File.Exists(pdbFile)) - { - items.Add( - new DependencyInfo( - ElementType.LibraryFile, - new XElement("file", - new XAttribute("src", Path.Combine(relativeOutputPath, Path.GetFileName(pdbFile))), - new XAttribute("target", Path.Combine(@"lib\net45\", Path.GetFileName(pdbFile))) - ))); - } - - var xmlFile = Path.ChangeExtension(file, ".xml"); - if (File.Exists(xmlFile)) - { - items.Add( - new DependencyInfo( - ElementType.LibraryFile, - new XElement("file", - new XAttribute("src", Path.Combine(relativeOutputPath, Path.GetFileName(xmlFile))), - new XAttribute("target", Path.Combine(@"lib\net45\", Path.GetFileName(xmlFile))) - ))); - } - } - - return items; - } } } diff --git a/VersionHistory.txt b/VersionHistory.txt index fe59b1f..2a45a06 100644 --- a/VersionHistory.txt +++ b/VersionHistory.txt @@ -1,8 +1,25 @@ -1.0.0: Initial -1.1.0: Added support for content files (files marked as content in NuGet project) -2.0.0: Only take content files under content folder (from NuGet project) -2.1.0: Take all files under content folder as content (from NuGet project) -2.2.0: Support packages used by project references. -2.3.0: Added optional config file (for NuGet projects), - now you can set icon and choose to add framework references to your NuGet packages -2.4.0: Added more config file options +1.0.0: + * Initial + +1.1.0: + * Added support for content files (files marked as content in NuGet project) + +2.0.0: + * Only take content files under content folder (from NuGet project) + +2.1.0: + * Take all files under content folder as content (from NuGet project) + +2.2.0: + * Support packages used by project references. + +2.3.0: + * Added optional config file (for NuGet projects), + now you can set icon and choose to add framework references to your NuGet packages + +2.4.0: + * Added more config file options + +2.5.0: + * Enabled including non-project references (e.g. 3rd party libraries under lib) + * Added Demo.Readme.txt for explaining demo of the various features diff --git a/VersionInfo.cs b/VersionInfo.cs index 0db424c..e268a9b 100644 --- a/VersionInfo.cs +++ b/VersionInfo.cs @@ -2,5 +2,5 @@ using System.Runtime.CompilerServices; using System.Runtime.InteropServices; -[assembly: AssemblyVersion("2.4.0.0")] -[assembly: AssemblyFileVersion("2.4.0.0")] +[assembly: AssemblyVersion("2.5.0.0")] +[assembly: AssemblyFileVersion("2.5.0.0")]