├── NuPack
├── Images
│ ├── nuspec.png
│ ├── NuPackBrowse.png
│ ├── NuPackConsole.png
│ ├── NuPackExplore.png
│ ├── NuPackOutput.png
│ ├── NuPackDirectory.png
│ └── NuPackAssemblyInfo.png
├── NuPack.Extension
│ ├── packages.config
│ ├── IPlugin.cs
│ ├── Properties
│ │ └── AssemblyInfo.cs
│ ├── Setting.cs
│ └── NuPack.Extension.csproj
├── NuPack
│ ├── packages.config
│ ├── NuPack.targets
│ ├── Template
│ ├── Properties
│ │ └── AssemblyInfo.cs
│ ├── NuPack.csproj
│ └── Program.cs
└── NuPack.sln
├── LICENSE.md
├── .gitattributes
├── README.md
└── .gitignore
/NuPack/Images/nuspec.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Puresharper/NuPack/HEAD/NuPack/Images/nuspec.png
--------------------------------------------------------------------------------
/NuPack/Images/NuPackBrowse.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Puresharper/NuPack/HEAD/NuPack/Images/NuPackBrowse.png
--------------------------------------------------------------------------------
/NuPack/Images/NuPackConsole.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Puresharper/NuPack/HEAD/NuPack/Images/NuPackConsole.png
--------------------------------------------------------------------------------
/NuPack/Images/NuPackExplore.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Puresharper/NuPack/HEAD/NuPack/Images/NuPackExplore.png
--------------------------------------------------------------------------------
/NuPack/Images/NuPackOutput.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Puresharper/NuPack/HEAD/NuPack/Images/NuPackOutput.png
--------------------------------------------------------------------------------
/NuPack/Images/NuPackDirectory.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Puresharper/NuPack/HEAD/NuPack/Images/NuPackDirectory.png
--------------------------------------------------------------------------------
/NuPack/Images/NuPackAssemblyInfo.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Puresharper/NuPack/HEAD/NuPack/Images/NuPackAssemblyInfo.png
--------------------------------------------------------------------------------
/NuPack/NuPack.Extension/packages.config:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
--------------------------------------------------------------------------------
/NuPack/NuPack/packages.config:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
--------------------------------------------------------------------------------
/NuPack/NuPack/NuPack.targets:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 | $(BuildDependsOn);
6 | NuPack
7 |
8 |
9 |
10 |
11 |
12 |
--------------------------------------------------------------------------------
/NuPack/NuPack/Template:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 | $(BuildDependsOn);
6 | [name]
7 |
8 |
9 |
10 |
11 |
12 |
--------------------------------------------------------------------------------
/NuPack/NuPack.Extension/IPlugin.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using NuGet;
3 |
4 | namespace NuPack.Extension
5 | {
6 | ///
7 | /// Plugin to reorganize package builder
8 | ///
9 | public interface IPlugin : IDisposable
10 | {
11 | ///
12 | /// Produce a new package builder based on original.
13 | ///
14 | /// Setting used to produce package
15 | /// Package builder
16 | ///
17 | PackageBuilder Update(Setting setting, PackageBuilder package);
18 | }
19 | }
20 |
--------------------------------------------------------------------------------
/NuPack/NuPack/Properties/AssemblyInfo.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.Reflection;
3 | using System.Runtime;
4 | using System.Runtime.InteropServices;
5 |
6 | [assembly: AssemblyTitle("NuPack .NET 4.0+")]
7 | [assembly: AssemblyDescription("NuPack .NET 4.0+ create a nuget package on build")]
8 | [assembly: AssemblyCompany("Tony THONG")]
9 | [assembly: AssemblyProduct("NuPack")]
10 | [assembly: AssemblyCopyright("Copyright © 2017 Tony THONG")]
11 | [assembly: AssemblyTrademark("NuPack")]
12 | [assembly: AssemblyCulture("")]
13 | [assembly: ComVisible(false)]
14 | [assembly: Guid("85c23e55-ec01-4202-8bf6-4c708374359b")]
15 | [assembly: AssemblyVersion("3.4.4")]
16 | [assembly: AssemblyFileVersion("3.4.4")]
17 | #if DEBUG
18 | [assembly: AssemblyConfiguration("Debug")]
19 | #else
20 | [assembly: AssemblyConfiguration("Release")]
21 | #endif
--------------------------------------------------------------------------------
/NuPack/NuPack.Extension/Properties/AssemblyInfo.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.Reflection;
3 | using System.Runtime;
4 | using System.Runtime.InteropServices;
5 |
6 | [assembly: AssemblyTitle("NuPack Extension .NET 4.0+")]
7 | [assembly: AssemblyDescription("NuPack Extension .NET 4.0+ provides interface to develop plugin for NuPack")]
8 | [assembly: AssemblyCompany("Tony THONG")]
9 | [assembly: AssemblyProduct("NuPack.Extension")]
10 | [assembly: AssemblyCopyright("Copyright © 2017 Tony THONG")]
11 | [assembly: AssemblyTrademark("NuPack")]
12 | [assembly: AssemblyCulture("")]
13 | [assembly: ComVisible(false)]
14 | [assembly: Guid("82d134c5-7c13-4845-b754-adb522e838ab")]
15 | [assembly: AssemblyVersion("2.1.0")]
16 | [assembly: AssemblyFileVersion("2.1.0")]
17 | #if DEBUG
18 | [assembly: AssemblyConfiguration("Debug")]
19 | #else
20 | [assembly: AssemblyConfiguration("Release")]
21 | #endif
--------------------------------------------------------------------------------
/LICENSE.md:
--------------------------------------------------------------------------------
1 | MIT License
2 |
3 | Copyright (c) 2017 Tony THONG
4 |
5 | Permission is hereby granted, free of charge, to any person obtaining a copy
6 | of this software and associated documentation files (the "Software"), to deal
7 | in the Software without restriction, including without limitation the rights
8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9 | copies of the Software, and to permit persons to whom the Software is
10 | furnished to do so, subject to the following conditions:
11 |
12 | The above copyright notice and this permission notice shall be included in all
13 | copies or substantial portions of the Software.
14 |
15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21 | SOFTWARE.
22 |
--------------------------------------------------------------------------------
/NuPack/NuPack.sln:
--------------------------------------------------------------------------------
1 |
2 | Microsoft Visual Studio Solution File, Format Version 12.00
3 | # Visual Studio 14
4 | VisualStudioVersion = 14.0.25420.1
5 | MinimumVisualStudioVersion = 10.0.40219.1
6 | Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "NuPack", "NuPack\NuPack.csproj", "{85C23E55-EC01-4202-8BF6-4C708374359B}"
7 | EndProject
8 | Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Images", "Images", "{C6BAED0B-2BF8-4C90-AB83-B6D11B2E0C96}"
9 | EndProject
10 | Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "NuPack.Extension", "NuPack.Extension\NuPack.Extension.csproj", "{82D134C5-7C13-4845-B754-ADB522E838AB}"
11 | EndProject
12 | Global
13 | GlobalSection(SolutionConfigurationPlatforms) = preSolution
14 | Debug|Any CPU = Debug|Any CPU
15 | Release|Any CPU = Release|Any CPU
16 | EndGlobalSection
17 | GlobalSection(ProjectConfigurationPlatforms) = postSolution
18 | {85C23E55-EC01-4202-8BF6-4C708374359B}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
19 | {85C23E55-EC01-4202-8BF6-4C708374359B}.Debug|Any CPU.Build.0 = Debug|Any CPU
20 | {85C23E55-EC01-4202-8BF6-4C708374359B}.Release|Any CPU.ActiveCfg = Release|Any CPU
21 | {85C23E55-EC01-4202-8BF6-4C708374359B}.Release|Any CPU.Build.0 = Release|Any CPU
22 | {82D134C5-7C13-4845-B754-ADB522E838AB}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
23 | {82D134C5-7C13-4845-B754-ADB522E838AB}.Debug|Any CPU.Build.0 = Debug|Any CPU
24 | {82D134C5-7C13-4845-B754-ADB522E838AB}.Release|Any CPU.ActiveCfg = Release|Any CPU
25 | {82D134C5-7C13-4845-B754-ADB522E838AB}.Release|Any CPU.Build.0 = Release|Any CPU
26 | EndGlobalSection
27 | GlobalSection(SolutionProperties) = preSolution
28 | HideSolutionNode = FALSE
29 | EndGlobalSection
30 | EndGlobal
31 |
--------------------------------------------------------------------------------
/NuPack/NuPack.Extension/Setting.cs:
--------------------------------------------------------------------------------
1 | using NuGet;
2 | using System;
3 |
4 | namespace NuPack.Extension
5 | {
6 | ///
7 | /// Setting used to call NuPack
8 | ///
9 | public class Setting
10 | {
11 | private string m_Solution;
12 | private string m_Project;
13 | private string m_Configuration;
14 | private string m_Plateform;
15 | private string m_Assembly;
16 |
17 | ///
18 | /// Setting
19 | ///
20 | /// Solution
21 | /// Project
22 | /// Configuration
23 | /// Plateform
24 | /// Assembly
25 | public Setting(string solution, string project, string configuration, string plateform, string assembly)
26 | {
27 | this.m_Solution = solution;
28 | this.m_Project = project;
29 | this.m_Configuration = configuration;
30 | this.m_Plateform = plateform;
31 | this.m_Assembly = assembly;
32 | }
33 |
34 | ///
35 | /// Solution.
36 | ///
37 | public string Solution
38 | {
39 | get { return this.m_Solution; }
40 | }
41 |
42 | ///
43 | /// Project.
44 | ///
45 | public string Project
46 | {
47 | get { return this.m_Project; }
48 | }
49 |
50 | ///
51 | /// Configuration.
52 | ///
53 | public string Configuration
54 | {
55 | get { return this.m_Solution; }
56 | }
57 |
58 | ///
59 | /// Plateform.
60 | ///
61 | public string Plateform
62 | {
63 | get { return this.m_Plateform; }
64 | }
65 |
66 | ///
67 | /// Assembly.
68 | ///
69 | public string Assembly
70 | {
71 | get { return this.m_Assembly; }
72 | }
73 | }
74 | }
75 |
--------------------------------------------------------------------------------
/.gitattributes:
--------------------------------------------------------------------------------
1 | ###############################################################################
2 | # Set default behavior to automatically normalize line endings.
3 | ###############################################################################
4 | * text=auto
5 |
6 | ###############################################################################
7 | # Set default behavior for command prompt diff.
8 | #
9 | # This is need for earlier builds of msysgit that does not have it on by
10 | # default for csharp files.
11 | # Note: This is only used by command line
12 | ###############################################################################
13 | #*.cs diff=csharp
14 |
15 | ###############################################################################
16 | # Set the merge driver for project and solution files
17 | #
18 | # Merging from the command prompt will add diff markers to the files if there
19 | # are conflicts (Merging from VS is not affected by the settings below, in VS
20 | # the diff markers are never inserted). Diff markers may cause the following
21 | # file extensions to fail to load in VS. An alternative would be to treat
22 | # these files as binary and thus will always conflict and require user
23 | # intervention with every merge. To do so, just uncomment the entries below
24 | ###############################################################################
25 | #*.sln merge=binary
26 | #*.csproj merge=binary
27 | #*.vbproj merge=binary
28 | #*.vcxproj merge=binary
29 | #*.vcproj merge=binary
30 | #*.dbproj merge=binary
31 | #*.fsproj merge=binary
32 | #*.lsproj merge=binary
33 | #*.wixproj merge=binary
34 | #*.modelproj merge=binary
35 | #*.sqlproj merge=binary
36 | #*.wwaproj merge=binary
37 |
38 | ###############################################################################
39 | # behavior for image files
40 | #
41 | # image files are treated as binary by default.
42 | ###############################################################################
43 | #*.jpg binary
44 | #*.png binary
45 | #*.gif binary
46 |
47 | ###############################################################################
48 | # diff behavior for common document formats
49 | #
50 | # Convert binary document formats to text before diffing them. This feature
51 | # is only available from the command line. Turn it on by uncommenting the
52 | # entries below.
53 | ###############################################################################
54 | #*.doc diff=astextplain
55 | #*.DOC diff=astextplain
56 | #*.docx diff=astextplain
57 | #*.DOCX diff=astextplain
58 | #*.dot diff=astextplain
59 | #*.DOT diff=astextplain
60 | #*.pdf diff=astextplain
61 | #*.PDF diff=astextplain
62 | #*.rtf diff=astextplain
63 | #*.RTF diff=astextplain
64 |
--------------------------------------------------------------------------------
/NuPack/NuPack.Extension/NuPack.Extension.csproj:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 | Debug
6 | AnyCPU
7 | {82D134C5-7C13-4845-B754-ADB522E838AB}
8 | Library
9 | Properties
10 | NuPack.Extension
11 | NuPack.Extension
12 | v4.0
13 | 512
14 |
15 |
16 | true
17 | full
18 | false
19 | bin\Debug\
20 | DEBUG;TRACE
21 | prompt
22 | 4
23 | bin\Debug\NuPack.Extension.XML
24 | false
25 |
26 |
27 | pdbonly
28 | true
29 | bin\Release\
30 | TRACE
31 | prompt
32 | 4
33 | bin\Release\NuPack.Extension.XML
34 | false
35 |
36 |
37 |
38 | ..\packages\Microsoft.Web.Xdt.2.1.1\lib\net40\Microsoft.Web.XmlTransform.dll
39 | True
40 |
41 |
42 | ..\packages\NuGet.Core.2.14.0\lib\net40-Client\NuGet.Core.dll
43 | True
44 |
45 |
46 |
47 |
48 |
49 |
50 |
51 |
52 |
53 |
54 |
55 |
56 |
57 |
58 |
59 |
60 |
61 |
62 |
69 |
--------------------------------------------------------------------------------
/README.md:
--------------------------------------------------------------------------------
1 | [](https://www.nuget.org/packages/NuPack)
2 |
3 | # NuPack
4 |
5 | NuPack is an easy way to produce a nuget package for .NET 4.0+ based on AssemblyInfo or nuspec when building with Visual Studio. It is materialized as a nuget package.
6 |
7 | When NuPack is reference by a project, no dependency is created, there is only a new build step to automatically pack the project output into a nuget package with project name as id.
8 |
9 | ## Features
10 | - **Nuspec : the manual way**
11 |
12 | When a .nuspec file is detected as part of project, NuPack respect the specification and dosen't apply any auto configuration to produce the expected nuget package.
13 |
14 | - **Library : the most common scenario**
15 |
16 | Produce a simple library (lib folder) with nuget package dependencies. This pattern is automatically apply when there is no .nuspec file detected for project of type library.
17 |
18 | - **Console : the build action**
19 |
20 | When package is based on console application and .nuspec is not declared, a build directory is defined with a .targets file to provide a simple way to add a build action step as post build with 5 arguments : $(SolutionPath), $(ProjectPath), $(Configuration), $(PlatformName) and $(TargetPath)
21 |
22 | - **Automatically include dependencies**
23 |
24 | Dependencies can be a nuget packages, project references, etc... They must be include recursively in the generated nuget package with an adequat form.
25 |
26 | - **Propagation of resources**
27 |
28 | Nuget process does not propagate xml documentation and resources of dependency in output and cannot be considered in NuPack packaging process. Allow NuPack to propagate them automatically help to keep a clean structure and documentation in each node.
29 |
30 | - **Extensibility pattern with custom nuget package** [](https://www.nuget.org/packages/NuPack.Extension)
31 |
32 | NuPack can provide a library to develop a plugin as nuget package. It will detect plugin from package.config and load it from NuPack folder to add additional behavior to NuPack. Plugin will be called with arguments passed to NuPack and produce a PackageBuilder from original PackageBuilder before save result. Plugin is disposed after nuget creation.
33 |
34 | - **Detection of NuPack Extension project to handle it**
35 |
36 | NuPack have to create a specific package to store plugin (library) in NuPack folder when project reference NuPack.Extension.
37 |
38 | ## Roadmap
39 | - **Optimizer pattern for console application**
40 |
41 | When NuPack is referenced by a console application named [Library].Optimizer and reference a library named [Library], an optimizer pattern is done. Generated nuget package contains the [Library].dll into lib folder and [Library].Optimizer.exe is placed into build folder with a .targets file to execute optimizer on postbuild with same arguments than standard build action for console application pattern. The nuget package will take [Library] name as id. It means that pattern is not done if [Library] is a nuget producer. Optimizer pattern will be an entry point to rewrite IL for example or prepare something based on [Library].dll usage.
42 |
43 | - **Support for Visual Studio 2017**
44 |
45 | Visual Studio 2017 changed nuget integration template. NuPack have to be updated to support Visual Studio 2017.
46 |
47 | - **Automatically detect relation between project and github.com to complete metadata**
48 |
49 | One of frustrating thing with nuget is to have a clean and full metadata. Unfortunately, AssemblyInfo does not provide a way to expose all nuget needs. In other hand, it is often necessary to declare in multiple place the same informations that cause synchronization issue and add a maintenance overhead. Using github.com api to automatically complete nuget creation can be a good thing to stay reactive.
50 |
51 |
52 | ## More
53 | - [How to create a nuget package using NuPack](https://www.codeproject.com/Tips/1190135/How-to-create-a-nuget-package-on-each-Visual-Studi)
54 | - [How to setup a managed postbuild with NuPack](https://www.codeproject.com/Tips/1190360/How-to-setup-a-managed-postbuild-without-scripting)
55 | - [How to extend NuPack to complete its behavior thanks to NuPack Extension 4.0+](https://www.codeproject.com/Tips/1190921/How-to-extend-NuPack-to-complement-its-behavior)
56 | - [Swagger4WCF use NuPack postbuild pattern](https://www.codeproject.com/Tips/1190441/How-to-generate-basic-swagger-yaml-description-for)
57 |
--------------------------------------------------------------------------------
/NuPack/NuPack/NuPack.csproj:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 | Debug
6 | AnyCPU
7 | {85C23E55-EC01-4202-8BF6-4C708374359B}
8 | Exe
9 | Properties
10 | NuPack
11 | NuPack
12 | v4.0
13 | 512
14 |
15 |
16 | AnyCPU
17 | true
18 | full
19 | false
20 | bin\Debug\
21 | DEBUG;TRACE
22 | prompt
23 | 4
24 | false
25 |
26 |
27 | AnyCPU
28 | none
29 | true
30 | bin\Release\
31 | TRACE
32 | prompt
33 | 4
34 | false
35 |
36 |
37 |
38 | ..\packages\Microsoft.Web.Xdt.2.1.1\lib\net40\Microsoft.Web.XmlTransform.dll
39 | True
40 |
41 |
42 | ..\packages\Mono.Cecil.0.9.6.4\lib\net40\Mono.Cecil.dll
43 | True
44 |
45 |
46 | ..\packages\Mono.Cecil.0.9.6.4\lib\net40\Mono.Cecil.Mdb.dll
47 | True
48 |
49 |
50 | ..\packages\Mono.Cecil.0.9.6.4\lib\net40\Mono.Cecil.Pdb.dll
51 | True
52 |
53 |
54 | ..\packages\Mono.Cecil.0.9.6.4\lib\net40\Mono.Cecil.Rocks.dll
55 | True
56 |
57 |
58 | ..\packages\NuGet.Core.2.14.0\lib\net40-Client\NuGet.Core.dll
59 | True
60 |
61 |
62 | ..\packages\NuPack.Extension.2.1.0\lib\net40\NuPack.Extension.dll
63 | True
64 |
65 |
66 |
67 |
68 |
69 |
70 |
71 |
72 |
73 |
74 |
75 |
76 |
77 |
78 |
79 | Always
80 |
81 |
82 |
83 |
84 |
85 |
92 |
--------------------------------------------------------------------------------
/.gitignore:
--------------------------------------------------------------------------------
1 | ## Ignore Visual Studio temporary files, build results, and
2 | ## files generated by popular Visual Studio add-ons.
3 |
4 | # User-specific files
5 | *.suo
6 | *.user
7 | *.userosscache
8 | *.sln.docstates
9 |
10 | # User-specific files (MonoDevelop/Xamarin Studio)
11 | *.userprefs
12 |
13 | # Build results
14 | [Dd]ebug/
15 | [Dd]ebugPublic/
16 | [Rr]elease/
17 | [Rr]eleases/
18 | [Xx]64/
19 | [Xx]86/
20 | [Bb]uild/
21 | bld/
22 | [Bb]in/
23 | [Oo]bj/
24 |
25 | # Visual Studio 2015 cache/options directory
26 | .vs/
27 | # Uncomment if you have tasks that create the project's static files in wwwroot
28 | #wwwroot/
29 |
30 | # MSTest test Results
31 | [Tt]est[Rr]esult*/
32 | [Bb]uild[Ll]og.*
33 |
34 | # NUNIT
35 | *.VisualState.xml
36 | TestResult.xml
37 |
38 | # Build Results of an ATL Project
39 | [Dd]ebugPS/
40 | [Rr]eleasePS/
41 | dlldata.c
42 |
43 | # DNX
44 | project.lock.json
45 | artifacts/
46 |
47 | *_i.c
48 | *_p.c
49 | *_i.h
50 | *.ilk
51 | *.meta
52 | *.obj
53 | *.pch
54 | *.pdb
55 | *.pgc
56 | *.pgd
57 | *.rsp
58 | *.sbr
59 | *.tlb
60 | *.tli
61 | *.tlh
62 | *.tmp
63 | *.tmp_proj
64 | *.log
65 | *.vspscc
66 | *.vssscc
67 | .builds
68 | *.pidb
69 | *.svclog
70 | *.scc
71 |
72 | # Chutzpah Test files
73 | _Chutzpah*
74 |
75 | # Visual C++ cache files
76 | ipch/
77 | *.aps
78 | *.ncb
79 | *.opendb
80 | *.opensdf
81 | *.sdf
82 | *.cachefile
83 | *.VC.db
84 |
85 | # Visual Studio profiler
86 | *.psess
87 | *.vsp
88 | *.vspx
89 | *.sap
90 |
91 | # TFS 2012 Local Workspace
92 | $tf/
93 |
94 | # Guidance Automation Toolkit
95 | *.gpState
96 |
97 | # ReSharper is a .NET coding add-in
98 | _ReSharper*/
99 | *.[Rr]e[Ss]harper
100 | *.DotSettings.user
101 |
102 | # JustCode is a .NET coding add-in
103 | .JustCode
104 |
105 | # TeamCity is a build add-in
106 | _TeamCity*
107 |
108 | # DotCover is a Code Coverage Tool
109 | *.dotCover
110 |
111 | # NCrunch
112 | _NCrunch_*
113 | .*crunch*.local.xml
114 | nCrunchTemp_*
115 |
116 | # MightyMoose
117 | *.mm.*
118 | AutoTest.Net/
119 |
120 | # Web workbench (sass)
121 | .sass-cache/
122 |
123 | # Installshield output folder
124 | [Ee]xpress/
125 |
126 | # DocProject is a documentation generator add-in
127 | DocProject/buildhelp/
128 | DocProject/Help/*.HxT
129 | DocProject/Help/*.HxC
130 | DocProject/Help/*.hhc
131 | DocProject/Help/*.hhk
132 | DocProject/Help/*.hhp
133 | DocProject/Help/Html2
134 | DocProject/Help/html
135 |
136 | # Click-Once directory
137 | publish/
138 |
139 | # Publish Web Output
140 | *.[Pp]ublish.xml
141 | *.azurePubxml
142 |
143 | # TODO: Un-comment the next line if you do not want to checkin
144 | # your web deploy settings because they may include unencrypted
145 | # passwords
146 | #*.pubxml
147 | *.publishproj
148 |
149 | # NuGet Packages
150 | *.nupkg
151 | # The packages folder can be ignored because of Package Restore
152 | **/packages/*
153 | # except build/, which is used as an MSBuild target.
154 | !**/packages/build/
155 | # Uncomment if necessary however generally it will be regenerated when needed
156 | #!**/packages/repositories.config
157 | # NuGet v3's project.json files produces more ignoreable files
158 | *.nuget.props
159 | *.nuget.targets
160 |
161 | # Microsoft Azure Build Output
162 | csx/
163 | *.build.csdef
164 |
165 | # Microsoft Azure Emulator
166 | ecf/
167 | rcf/
168 |
169 | # Windows Store app package directory
170 | AppPackages/
171 | BundleArtifacts/
172 |
173 | # Visual Studio cache files
174 | # files ending in .cache can be ignored
175 | *.[Cc]ache
176 | # but keep track of directories ending in .cache
177 | !*.[Cc]ache/
178 |
179 | # Others
180 | ClientBin/
181 | [Ss]tyle[Cc]op.*
182 | ~$*
183 | *~
184 | *.dbmdl
185 | *.dbproj.schemaview
186 | *.pfx
187 | *.publishsettings
188 | node_modules/
189 | orleans.codegen.cs
190 |
191 | # RIA/Silverlight projects
192 | Generated_Code/
193 |
194 | # Backup & report files from converting an old project file
195 | # to a newer Visual Studio version. Backup files are not needed,
196 | # because we have git ;-)
197 | _UpgradeReport_Files/
198 | Backup*/
199 | UpgradeLog*.XML
200 | UpgradeLog*.htm
201 |
202 | # SQL Server files
203 | *.mdf
204 | *.ldf
205 |
206 | # Business Intelligence projects
207 | *.rdl.data
208 | *.bim.layout
209 | *.bim_*.settings
210 |
211 | # Microsoft Fakes
212 | FakesAssemblies/
213 |
214 | # GhostDoc plugin setting file
215 | *.GhostDoc.xml
216 |
217 | # Node.js Tools for Visual Studio
218 | .ntvs_analysis.dat
219 |
220 | # Visual Studio 6 build log
221 | *.plg
222 |
223 | # Visual Studio 6 workspace options file
224 | *.opt
225 |
226 | # Visual Studio LightSwitch build output
227 | **/*.HTMLClient/GeneratedArtifacts
228 | **/*.DesktopClient/GeneratedArtifacts
229 | **/*.DesktopClient/ModelManifest.xml
230 | **/*.Server/GeneratedArtifacts
231 | **/*.Server/ModelManifest.xml
232 | _Pvt_Extensions
233 |
234 | # LightSwitch generated files
235 | GeneratedArtifacts/
236 | ModelManifest.xml
237 |
238 | # Paket dependency manager
239 | .paket/paket.exe
240 |
241 | # FAKE - F# Make
242 | .fake/
243 |
--------------------------------------------------------------------------------
/NuPack/NuPack/Program.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.Collections;
3 | using System.Collections.Generic;
4 | using System.IO;
5 | using System.Linq;
6 | using System.Reflection;
7 | using System.Xml;
8 | using System.Xml.Linq;
9 | using System.Text;
10 | using System.Threading;
11 | using Mono.Cecil;
12 | using NuGet;
13 | using NuPack.Extension;
14 |
15 | namespace NuCreate
16 | {
17 | static public class Program
18 | {
19 | static private string m_Native = BitConverter.ToString(typeof(object).Assembly.GetName().GetPublicKeyToken()).Replace("-", string.Empty);
20 |
21 | static public void Main(string[] arguments)
22 | {
23 | Program.Create(arguments[0], arguments[1], arguments[2], arguments[3], arguments[4]);
24 | }
25 |
26 | static private Manifest Open(string filename)
27 | {
28 | using (var _stream = File.Open(filename, FileMode.Open))
29 | {
30 | return Manifest.ReadFrom(_stream, true);
31 | }
32 | }
33 |
34 | static private string Metadata(this AssemblyDefinition assembly)
35 | where T : Attribute
36 | {
37 | var _attribute = assembly.CustomAttributes.FirstOrDefault(_Attribute => _Attribute.AttributeType.Resolve() == assembly.MainModule.Import(typeof(T)).Resolve());
38 | if (_attribute == null) { return null; }
39 | var _value = _attribute.ConstructorArguments.Single().Value.ToString();
40 | if (string.IsNullOrWhiteSpace(_value)) { return null; }
41 | return _value;
42 | }
43 |
44 | static private void Try(Action action)
45 | {
46 | var _index = 0;
47 | while (true)
48 | {
49 | try
50 | {
51 | action();
52 | break;
53 | }
54 | catch
55 | {
56 | if (++_index > 10) { throw; }
57 | Thread.Sleep(64);
58 | }
59 | }
60 | }
61 |
62 | static private IEnumerable Resources(string project, string configuration, bool dependency)
63 | {
64 | var _directory = Path.GetDirectoryName(project);
65 | var _document = XDocument.Load(project);
66 | var _namespace = _document.Root.Name.Namespace;
67 | foreach (var _element in _document.Descendants(_namespace.GetName("OutputPath")))
68 | {
69 | foreach (var _attribute in _element.Parent.Attributes())
70 | {
71 | if (_attribute.Value.Contains(configuration))
72 | {
73 | if (dependency)
74 | {
75 | foreach (var _package in Directory.EnumerateFiles(string.Concat(_directory, @"\", _element.Value), "*.nupkg"))
76 | {
77 | foreach (var _resource in new ZipPackage(_package).GetLibFiles())
78 | {
79 | if (_resource.IsEmptyFolder()) { continue; }
80 | yield return Path.GetFileName(_resource.Path);
81 | }
82 | }
83 | }
84 | foreach (var _project in _document.Descendants(_namespace.GetName("ProjectReference")).Select(_Reference => string.Concat(_directory, @"\", _Reference.Attribute("Include").Value)))
85 | {
86 | foreach (var _resource in Program.Resources(_project, configuration, true))
87 | {
88 | yield return _resource;
89 | }
90 | }
91 | yield break;
92 | }
93 | }
94 | }
95 | }
96 |
97 | static private IEnumerable Extends(IEnumerable dependencies, Setting setting, ref PackageBuilder package)
98 | {
99 | var _plugins = new List();
100 | var _solution = Path.GetDirectoryName(setting.Solution);
101 | foreach (var _dependency in dependencies)
102 | {
103 | var _directory = string.Concat(_solution, @"\packages\", _dependency.Id, ".", _dependency.Version, @"\NuPack");
104 | if (Directory.Exists(_directory))
105 | {
106 | foreach (var _library in Directory.EnumerateFiles(_directory, "*.dll"))
107 | {
108 | try
109 | {
110 | var _assembly = Assembly.LoadFrom(_library);
111 | var _identity = BitConverter.ToString(_assembly.GetName().GetPublicKeyToken()).Replace("-", string.Empty);
112 | if (string.Equals(_identity, Program.m_Native, StringComparison.InvariantCultureIgnoreCase)) { continue; }
113 | foreach (var _type in _assembly.GetTypes())
114 | {
115 | if (!_type.IsAbstract && typeof(IPlugin).IsAssignableFrom(_type))
116 | {
117 | var _constructor = _type.GetConstructor(BindingFlags.Instance | BindingFlags.NonPublic | BindingFlags.Public, null, Type.EmptyTypes, null);
118 | if (_constructor == null) { continue; }
119 | _plugins.Add(Activator.CreateInstance(_type, true) as IPlugin);
120 | }
121 | }
122 | }
123 | catch { continue; }
124 | }
125 | }
126 | }
127 | foreach (var _plugin in _plugins) { package = _plugin.Update(setting, package); }
128 | _plugins.Reverse();
129 | return _plugins;
130 | }
131 |
132 | static private string Specification(string project)
133 | {
134 | var _document = XDocument.Load(project);
135 | var _namespace = _document.Root.Name.Namespace;
136 | var _element = _document.Descendants(_namespace.GetName("None")).SingleOrDefault(_Element => _Element.Attribute("Include") != null && _Element.Attribute("Include").Value.EndsWith(".nuspec", StringComparison.CurrentCultureIgnoreCase));
137 |
138 | // Path.Combine is essentially useless
139 | // see http://thingsihateaboutmicrosoft.blogspot.com/2009/08/pathcombine-is-essentially-useless.html
140 | string _Path2 = _element.Attribute("Include").Value;
141 | if (Path.IsPathRooted(_Path2))
142 | {
143 | _Path2 = _Path2.TrimStart(Path.DirectorySeparatorChar);
144 | _Path2 = _Path2.TrimStart(Path.AltDirectorySeparatorChar);
145 | }
146 | return _element == null ? null : Path.Combine(Path.GetDirectoryName(project), _Path2);
147 | }
148 |
149 |
150 | static private string Save(string directory, PackageBuilder package)
151 | {
152 | var _filename = $@"{ directory }\{ package.Id }.{ package.Version }.nupkg";
153 | using (var _memory = new MemoryStream())
154 | {
155 | package.Save(_memory);
156 | _memory.Seek(0L, SeekOrigin.Begin);
157 | Program.Try(() => { if (File.Exists(_filename)) { File.Delete(_filename); } });
158 | using (var _stream = File.Open(_filename, FileMode.Create)) { _memory.CopyTo(_stream); }
159 | }
160 | return _filename;
161 | }
162 |
163 | static private IEnumerable Bin(string directory, params string[] exclusion)
164 | {
165 | foreach (var _filename in Directory.EnumerateFiles(directory))
166 | {
167 | var _name = Path.GetFileName(_filename);
168 | if (exclusion != null && exclusion.Any(_Name => string.Equals(_Name, _name, StringComparison.CurrentCultureIgnoreCase))) { continue; }
169 | if (_name.EndsWith(".vshost.exe", StringComparison.CurrentCultureIgnoreCase) || _name.EndsWith(".vshost.exe.manifest", StringComparison.CurrentCultureIgnoreCase)) { continue; }
170 | if (_name.EndsWith(".nupkg", StringComparison.CurrentCultureIgnoreCase) || _name.EndsWith(".pdb", StringComparison.CurrentCultureIgnoreCase) || _name.EndsWith(".tmp", StringComparison.CurrentCultureIgnoreCase) || _name.EndsWith(".bak", StringComparison.CurrentCultureIgnoreCase)) { continue; }
171 | yield return _filename;
172 | }
173 | }
174 |
175 | static private ZipPackage Template()
176 | {
177 | using (var _stream = typeof(Program).Assembly.GetManifestResourceStream("NuPack.Template.1.0.0.nupkg"))
178 | {
179 | return new ZipPackage(_stream);
180 | }
181 | }
182 |
183 | static private void Create(string solution, string project, string configuration, string plateform, string assembly)
184 | {
185 | var _assembly = AssemblyDefinition.ReadAssembly(assembly);
186 | var _name = _assembly.Name.Name;
187 | var _version = _assembly.Metadata();
188 | var _directory = Path.GetDirectoryName(assembly);
189 | var _dependencies = new PackageReferenceFile(string.Concat(Path.GetDirectoryName(project), @"\packages.config")).GetPackageReferences().Where(_Package => _Package.Id != "NuPack").ToArray();
190 | var _extension = _dependencies.Any(_Dependency => _Dependency.Id == "NuPack.Extension");
191 | var _setting = new Setting(solution, project, configuration, plateform, assembly);
192 | var _specification = Program.Specification(project);
193 | if (_specification == null)
194 | {
195 | var _builder = typeof(PackageBuilder).GetConstructor(BindingFlags.Instance | BindingFlags.NonPublic | BindingFlags.Public, null, new Type[] { typeof(bool) }, null).Invoke(new object[] { true }) as PackageBuilder;
196 | var _metadata = new ManifestMetadata()
197 | {
198 | Id = _name,
199 | Title = _assembly.Metadata() ?? _name,
200 | Authors = _assembly.Metadata() ?? "-",
201 | Version = _version,
202 | Summary = _assembly.Metadata() ?? (_assembly.Metadata() ?? "-"),
203 | Description = _assembly.Metadata() ?? "-",
204 | Copyright = _assembly.Metadata() ?? "-"
205 | };
206 | _builder.Populate(_metadata);
207 | if (assembly.EndsWith(".exe", StringComparison.CurrentCultureIgnoreCase))
208 | {
209 | if (_extension) { throw new NotSupportedException(); }
210 | var _targets = string.Concat(assembly.Substring(0, assembly.Length - 4), ".targets");
211 | _builder.PopulateFiles(null, Program.Bin(_directory).Select(_Filename => new ManifestFile() { Source = _Filename, Target = "build" }));
212 | var _plugins = Program.Extends(_dependencies, _setting, ref _builder);
213 | Program.Try(() => { if (File.Exists(_targets)) { File.Delete(_targets); } });
214 | using (var _stream = typeof(Program).Assembly.GetManifestResourceStream("NuPack.Template")) { File.WriteAllText(_targets, new StreamReader(_stream).ReadToEnd().Replace("[name]", _name).Replace("[version]", _builder.Version.ToOriginalString()), Encoding.UTF8); }
215 | var _filename = Program.Save(_directory, _builder);
216 | Program.Try(() => { if (File.Exists(_targets)) { File.Delete(_targets); } });
217 | Console.WriteLine($"{ _name } -> { _filename }");
218 | foreach (var _plugin in _plugins) { _plugin.Dispose(); }
219 | }
220 | else
221 | {
222 | if (_extension)
223 | {
224 | _builder.Files.AddRange(Program.Template().GetContentFiles());
225 | _builder.PopulateFiles(null, Program.Bin(_directory, "Microsoft.Web.XmlTransform.dll", "NuGet.Core.dll", "NuPack.Extension.dll", "NuPack.Extension.xml").Select(_Filename => new ManifestFile() { Source = _Filename, Target = $"NuPack" }));
226 | var _plugins = Program.Extends(_dependencies, _setting, ref _builder);
227 | Console.WriteLine($"{ _name } -> { Program.Save(_directory, _builder) }");
228 | foreach (var _plugin in _plugins) { _plugin.Dispose(); }
229 | }
230 | else
231 | {
232 | var _dictionary = _dependencies.Select(_Dependency => string.Concat(solution, @"packages\", _Dependency.Id, ".", _Dependency.Version, @"\lib")).Where(_Library => Directory.Exists(_Library)).SelectMany(_Library => Directory.EnumerateFiles(_Library, "*", SearchOption.AllDirectories)).ToArray();
233 | foreach (var _dependency in _dependencies.GroupBy(_Package => _Package.TargetFramework)) { _builder.DependencySets.Add(new PackageDependencySet(_dependency.Key, _dependency.Select(_Package => new PackageDependency(_Package.Id, _Package.VersionConstraint, null, null)))); }
234 | var _targets = string.Concat(assembly.Substring(0, assembly.Length - 4), ".targets");
235 | if (_dictionary.Any(_Resource => !_Resource.EndsWith(".dll", StringComparison.CurrentCultureIgnoreCase)))
236 | {
237 | using (var _stream = typeof(Program).Assembly.GetManifestResourceStream("NuPack.Template"))
238 | {
239 | var _document = XDocument.Parse(new StreamReader(_stream).ReadToEnd().Replace("[name]", _name), LoadOptions.PreserveWhitespace);
240 | var _namespace = _document.Root.Name.Namespace;
241 | var _sequence = _document.Descendants(_namespace.GetName("Target")).Single();
242 | _sequence.RemoveNodes();
243 | foreach (var _dependency in _dependencies)
244 | {
245 | var _library = string.Concat(solution, @"packages\", _dependency.Id, ".", _dependency.Version.ToOriginalString(), @"\lib");
246 | if (Directory.Exists(_library))
247 | {
248 | foreach (var _resource in Directory.EnumerateFiles(_library).Select(_Filename => Path.GetFileName(_Filename)))
249 | {
250 | if (_resource.EndsWith(".dll", StringComparison.CurrentCultureIgnoreCase)) { continue; }
251 | _sequence.Add(new XElement(_namespace.GetName("Exec"), new XAttribute("Command", $"xcopy /f /q /y \"$(SolutionDir)packages\\{ _dependency.Id }.{ _dependency.Version }\\lib\\{ _resource }\" \"$(ProjectDir)$(OutDir)*\" > nul")));
252 | }
253 | }
254 | }
255 | File.WriteAllText(_targets, _document.ToString(), Encoding.UTF8);
256 | _builder.PopulateFiles(null, new ManifestFile[] { new ManifestFile() { Source = _targets, Target = $"build" } });
257 | }
258 | }
259 | var _framework = $"lib/net{ _assembly.MainModule.RuntimeVersion[1] }{ _assembly.MainModule.RuntimeVersion[3] }/";
260 | var _resources = _dictionary.Select(_Resource => Path.GetFileName(_Resource)).Concat(Program.Resources(project, configuration, false)).Select(_Resource => _Resource.ToLower()).Distinct().ToArray();
261 | _builder.PopulateFiles(null, Program.Bin(_directory, Path.GetFileName(_targets)).Where(_Resource => !_resources.Contains(Path.GetFileName(_Resource).ToLower())).Select(_Resource => new ManifestFile() { Source = _Resource, Target = _framework }));
262 | var _plugins = Program.Extends(_dependencies, _setting, ref _builder);
263 | var _filename = Program.Save(_directory, _builder);
264 | Program.Try(() => { if (File.Exists(_targets)) { File.Delete(_targets); } });
265 | Console.WriteLine($"{ _name } -> { _filename }");
266 | foreach (var _plugin in _plugins) { _plugin.Dispose(); }
267 | }
268 | }
269 | }
270 | else
271 | {
272 | var _builder = new PackageBuilder();
273 | var _manifest = Program.Open(_specification);
274 | _builder.Populate(_manifest.Metadata);
275 | _builder.PopulateFiles(null, _manifest.Files);
276 | var _plugins = Program.Extends(_dependencies, _setting, ref _builder);
277 | Console.WriteLine($"{ _name } -> { Program.Save(_directory, _builder) }");
278 | foreach (var _plugin in _plugins) { _plugin.Dispose(); }
279 | }
280 | }
281 | }
282 | }
283 |
--------------------------------------------------------------------------------