├── .gitattributes
├── .gitignore
├── Gruntfile.js
├── LICENSE
├── README.md
├── libs
├── nuget.exe
└── nuget.js
├── package.json
├── tasks
├── nuget-key.js
├── nuget-pack.js
├── nuget-push.js
├── nuget-restore.js
└── nuget-update.js
└── tests
├── Package.nuspec
└── packages.config
/.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 |
--------------------------------------------------------------------------------
/.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 | *.sln.docstates
8 | *.sln
9 | *.*proj
10 |
11 | # Build results
12 | [Dd]ebug/
13 | [Rr]elease/
14 | x64/
15 | build/
16 | [Bb]in/
17 | [Oo]bj/
18 |
19 | node_modules/
20 | *.nupkg
21 |
22 | # Enable "build/" folder in the NuGet Packages folder since NuGet packages use it for MSBuild targets
23 | !packages/*/build/
24 |
25 | # MSTest test Results
26 | [Tt]est[Rr]esult*/
27 | [Bb]uild[Ll]og.*
28 |
29 | *_i.c
30 | *_p.c
31 | *.ilk
32 | *.meta
33 | *.obj
34 | *.pch
35 | *.pdb
36 | *.pgc
37 | *.pgd
38 | *.rsp
39 | *.sbr
40 | *.tlb
41 | *.tli
42 | *.tlh
43 | *.tmp
44 | *.tmp_proj
45 | *.log
46 | *.vspscc
47 | *.vssscc
48 | .builds
49 | *.pidb
50 | *.log
51 | *.scc
52 |
53 | # Visual C++ cache files
54 | ipch/
55 | *.aps
56 | *.ncb
57 | *.opensdf
58 | *.sdf
59 | *.cachefile
60 |
61 | # Visual Studio profiler
62 | *.psess
63 | *.vsp
64 | *.vspx
65 |
66 | # Guidance Automation Toolkit
67 | *.gpState
68 |
69 | # ReSharper is a .NET coding add-in
70 | _ReSharper*/
71 | *.[Rr]e[Ss]harper
72 |
73 | # TeamCity is a build add-in
74 | _TeamCity*
75 |
76 | # DotCover is a Code Coverage Tool
77 | *.dotCover
78 |
79 | # NCrunch
80 | *.ncrunch*
81 | .*crunch*.local.xml
82 |
83 | # Installshield output folder
84 | [Ee]xpress/
85 |
86 | # DocProject is a documentation generator add-in
87 | DocProject/buildhelp/
88 | DocProject/Help/*.HxT
89 | DocProject/Help/*.HxC
90 | DocProject/Help/*.hhc
91 | DocProject/Help/*.hhk
92 | DocProject/Help/*.hhp
93 | DocProject/Help/Html2
94 | DocProject/Help/html
95 |
96 | # Click-Once directory
97 | publish/
98 |
99 | # Publish Web Output
100 | *.Publish.xml
101 |
102 | # NuGet Packages Directory
103 | ## TODO: If you have NuGet Package Restore enabled, uncomment the next line
104 | packages/
105 |
106 | # Windows Azure Build Output
107 | csx
108 | *.build.csdef
109 |
110 | # Windows Store app package directory
111 | AppPackages/
112 |
113 | # Others
114 | sql/
115 | *.Cache
116 | ClientBin/
117 | [Ss]tyle[Cc]op.*
118 | ~$*
119 | *~
120 | *.dbmdl
121 | *.[Pp]ublish.xml
122 | *.pfx
123 | *.publishsettings
124 |
125 | # RIA/Silverlight projects
126 | Generated_Code/
127 |
128 | # Backup & report files from converting an old project file to a newer
129 | # Visual Studio version. Backup files are not needed, because we have git ;-)
130 | _UpgradeReport_Files/
131 | Backup*/
132 | UpgradeLog*.XML
133 | UpgradeLog*.htm
134 |
135 | # SQL Server files
136 | App_Data/*.mdf
137 | App_Data/*.ldf
138 |
139 |
140 | #LightSwitch generated files
141 | GeneratedArtifacts/
142 | _Pvt_Extensions/
143 | ModelManifest.xml
144 |
145 | # =========================
146 | # Windows detritus
147 | # =========================
148 |
149 | # Windows image file caches
150 | Thumbs.db
151 | ehthumbs.db
152 |
153 | # Folder config file
154 | Desktop.ini
155 |
156 | # Recycle Bin used on file shares
157 | $RECYCLE.BIN/
158 |
159 | # Mac desktop service store files
160 | .DS_Store
161 |
--------------------------------------------------------------------------------
/Gruntfile.js:
--------------------------------------------------------------------------------
1 | module.exports = function (grunt) {
2 | grunt.initConfig({
3 | nugetpack: {
4 | options: {
5 | verbosity: "detailed"
6 | },
7 |
8 | dist: {
9 | src: 'tests/Package.nuspec',
10 | dest: 'tests/'
11 | }
12 | },
13 | nugetrestore: {
14 | restore: {
15 | src: 'tests/packages.config',
16 | dest: 'packages/'
17 | }
18 | },
19 | nugetupdate: {
20 | update: {
21 | src: 'tests/project.sln'
22 | }
23 | },
24 | clean: {
25 | pack: {
26 | src: 'tests/PackageTest.1.0.0.nupkg'
27 | },
28 | restore: {
29 | src: 'packages'
30 | }
31 | }
32 | });
33 |
34 | grunt.loadNpmTasks('grunt-contrib-clean');
35 | grunt.loadTasks('tasks');
36 |
37 | grunt.registerTask('default', ['clean', 'nugetpack', 'nugetrestore']);
38 | };
--------------------------------------------------------------------------------
/LICENSE:
--------------------------------------------------------------------------------
1 | Copyright (c) 2013 SPA Tools
2 |
3 | Permission is hereby granted, free of charge, to any person
4 | obtaining a copy of this software and associated documentation
5 | files (the "Software"), to deal in the Software without restriction,
6 | including without limitation the rights to use, copy, modify, merge,
7 | publish, distribute, sublicense, and/or sell copies of the Software,
8 | and to permit persons to whom the Software is furnished to do so,
9 | subject to the following conditions:
10 |
11 | The above copyright notice and this permission notice shall be
12 | included in all copies or substantial portions of the Software.
13 |
14 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
15 | EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES
16 | OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
17 | IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR
18 | ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF
19 | CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
20 | WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
--------------------------------------------------------------------------------
/README.md:
--------------------------------------------------------------------------------
1 | # grunt-nuget [](http://badge.fury.io/js/grunt-nuget)
2 |
3 | [Grunt][grunt] NuGet Interface - Create and publish your NuGet packages using GruntJS.
4 |
5 | ## Getting Started
6 |
7 | Install this grunt plugin next to your project's gruntfile with: `npm install grunt-nuget --save-dev`
8 |
9 | NOTE : if you are on a unix system, you should install [Mono][mono] first.
10 |
11 | Then add this line to your project's `Gruntfile.js` :
12 |
13 | ```javascript
14 | grunt.loadNpmTasks('grunt-nuget');
15 | ```
16 |
17 | Then specify your config:
18 |
19 | ```javascript
20 | grunt.initConfig({
21 | ```
22 |
23 | For package creation : ([more informations][pack-options])
24 |
25 | ```javascript
26 | nugetpack: {
27 | dist: {
28 | src: 'tests/Package.nuspec',
29 | dest: 'tests/'
30 | }
31 | }
32 | ```
33 |
34 | For package publication : ([more informations][push-options])
35 |
36 | ```javascript
37 | nugetpush: {
38 | dist: {
39 | src: 'tests/*.nupkg',
40 |
41 | options: {
42 | apiKey: 'XXXXXXXX-XXXX-XXXX-XXXX-XXXXXXXXXXXX'
43 | }
44 | }
45 | }
46 | ```
47 |
48 | For package restore : ([more informations][restore-options])
49 |
50 | ```javascript
51 | nugetrestore: {
52 | restore: {
53 | src: 'tests/packages.config',
54 | dest: 'packages/'
55 | }
56 | }
57 | ```
58 |
59 | For project update : ([more informations][update-options])
60 |
61 | ```javascript
62 | nugetupdate: {
63 | update: {
64 | src: 'project.sln'
65 | }
66 | }
67 | ```
68 |
69 | ```javascript
70 | });
71 | ```
72 |
73 | In order to avoid specifying your API Key inside your `Gruntfile` you can use command line task : ([more informations][key-options])
74 |
75 | ```
76 | grunt nugetkey --key=XXXXXXXX-XXXX-XXXX-XXXX-XXXXXXXXXXXX
77 | ```
78 |
79 | [grunt]: https://github.com/gruntjs/grunt
80 | [mono]: http://www.go-mono.com/mono-downloads/download.html
81 | [pack-options]: https://github.com/spatools/grunt-nuget/wiki/Pack-Options
82 | [push-options]: https://github.com/spatools/grunt-nuget/wiki/Push-Options
83 | [restore-options]: https://github.com/spatools/grunt-nuget/wiki/Restore-Options
84 | [update-options]: https://github.com/spatools/grunt-nuget/wiki/Update-Options
85 | [key-options]: https://github.com/spatools/grunt-nuget/wiki/Key-Options
86 |
87 | ## Release History
88 | * 0.1.0 Initial Release
89 | * 0.1.1 Fix issue with OutputDirectory in NuGet Push
90 | * 0.1.2
91 | * Update NuGet.exe to version 2.8
92 | * Add support for csproj files in nugetpack command.
93 | * 0.1.3
94 | * Add package restore command
95 | * Added mono support on platforms other than windows
96 | * Fix issue when nuget-pack destination directory does not exists
97 | * 0.1.4
98 | * Update NuGet.exe to version 2.8.2
99 | * Fix issue in options parsing.
100 | * 0.1.5
101 | * Update NuGet.exe to version 3.2.0
102 | * 0.1.6
103 | * Update NuGet.exe to version 3.4.4
104 | * Add default `Source` option in `push` task to allow backward compatibility
105 | * 0.1.7
106 | * Update NuGet.exe to version 3.5.0
107 | * 0.2.0
108 | * Add task nugetupdate
109 | * 0.3.0
110 | * Update NuGet.exe to version 4.1
111 | * 0.3.1
112 | * Update NuGet.exe to version 4.7.1
--------------------------------------------------------------------------------
/libs/nuget.exe:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/spatools/grunt-nuget/db036952f4666de4bf0f30e47ec34b63bf18dc45/libs/nuget.exe
--------------------------------------------------------------------------------
/libs/nuget.js:
--------------------------------------------------------------------------------
1 | /*
2 | * grunt-nuget
3 | * https://github.com/spatools/grunt-nuget
4 | * Copyright (c) 2013 SPA Tools
5 | * Code below is licensed under MIT License
6 | *
7 | * Permission is hereby granted, free of charge, to any person
8 | * obtaining a copy of this software and associated documentation
9 | * files (the "Software"), to deal in the Software without restriction,
10 | * including without limitation the rights to use, copy, modify, merge,
11 | * publish, distribute, sublicense, and/or sell copies of the Software,
12 | * and to permit persons to whom the Software is furnished to do so,
13 | * subject to the following conditions:
14 | *
15 | * The above copyright notice and this permission notice shall be
16 | * included in all copies or substantial portions of the Software.
17 | *
18 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
19 | * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES
20 | * OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
21 | * IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR
22 | * ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF
23 | * CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
24 | * WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
25 | */
26 |
27 | var path = require("path");
28 | var nugetPath = path.join(__dirname, "nuget.exe");
29 |
30 | module.exports = function (grunt) {
31 | var _ = grunt.util._,
32 | useMono = (process.platform !== 'win32'),
33 | executable = useMono ? 'mono' : nugetPath;
34 |
35 | createArguments = function (command, path, args) {
36 | var result = [];
37 |
38 | if (useMono) {
39 | result.push(nugetPath);
40 | }
41 |
42 | result.push(command);
43 | result.push(path);
44 |
45 | for (var key in args) {
46 | var argKey = "-" + key[0].toUpperCase() + key.slice(1);
47 | result.push(argKey);
48 |
49 | if (args[key] && args[key] !== true)
50 | result.push(args[key]);
51 | }
52 |
53 | return result;
54 | },
55 |
56 | createSpawnCallback = function (path, args, callback) {
57 | return function (error, result, code) {
58 | if (error) {
59 | var _error = "Error while trying to execute NuGet Command Line on file " + path + "\n" + error;
60 | callback(error);
61 | }
62 | else {
63 | if ("verbose" in args || "verbosity" in args) {
64 | grunt.log.writeln(result);
65 | }
66 |
67 | grunt.log.ok();
68 | callback();
69 | }
70 | }
71 | },
72 |
73 | isSpecFile = function (file) {
74 | return path.extname(file) === ".nuspec" || path.extname(file) === ".csproj";
75 | },
76 |
77 | isPackageFile = function (file) {
78 | return path.extname(file) === ".nupkg";
79 | },
80 | isSolutionFile = function (file) {
81 | return path.extname(file) === ".sln";
82 | },
83 | isConfigFile = function (file) {
84 | return path.basename(file) === "packages.config";
85 | },
86 |
87 | pack = function (path, args, callback) {
88 | if (!isSpecFile(path)) {
89 | callback("File path '" + path + "' is not a NuGet specification file !");
90 | return;
91 | }
92 |
93 | grunt.log.writeln("Trying to create NuGet package from " + path + ". ");
94 | grunt.util.spawn({ cmd: executable, args: createArguments("Pack", path, args) }, createSpawnCallback(path, args, callback));
95 | },
96 |
97 | push = function (path, args, callback) {
98 | if (!isPackageFile(path)) {
99 | callback("File path '" + path + "' is not a NuGet package file !");
100 | return;
101 | }
102 |
103 | grunt.log.writeln("Trying to publish NuGet package " + path + ". ");
104 | grunt.util.spawn({ cmd: executable, args: createArguments("Push", path, args) }, createSpawnCallback(path, args, callback));
105 | },
106 | restore = function (path, args, callback) {
107 | if (!isSolutionFile(path) && !isConfigFile(path)) {
108 | callback("File path '" + path + "' is not a valid solution file or packages.config !");
109 | return;
110 | }
111 |
112 | grunt.log.writeln("Trying to restore NuGet packages for " + path + ". ");
113 | grunt.util.spawn({ cmd: executable, args: createArguments("Restore", path, args) }, createSpawnCallback(path, args, callback));
114 | },
115 | update = function (path, args, callback) {
116 | if (!isSolutionFile(path)) {
117 | callback("File path '" + path + "' is not a valid solution file!");
118 | return;
119 | }
120 |
121 | grunt.log.writeln("Trying to update NuGet packages for " + path + ". ");
122 | grunt.util.spawn({ cmd: executable, args: createArguments("Update", path, args) }, createSpawnCallback(path, args, callback));
123 | },
124 | setapikey = function (key, args, callback) {
125 | grunt.util.spawn({ cmd: executable, args: createArguments("SetApiKey", key, args) }, createSpawnCallback(null, args, callback));
126 | };
127 |
128 | return {
129 | isSpecFile: isSpecFile,
130 | isPackageFile: isPackageFile,
131 |
132 | pack: pack,
133 | push: push,
134 | restore: restore,
135 | update: update,
136 | setapikey: setapikey
137 | };
138 | };
139 |
--------------------------------------------------------------------------------
/package.json:
--------------------------------------------------------------------------------
1 | {
2 | "name": "grunt-nuget",
3 | "description": "Grunt NuGet interface - Prepare, package and publish your application in NuGet gallery using Grunt JS",
4 | "version": "0.3.1",
5 | "homepage": "https://github.com/spatools/grunt-nuget.git",
6 | "license": "MIT",
7 | "author": {
8 | "name": "SPA Tools",
9 | "url": "http://github.com/spatools/"
10 | },
11 | "repository": {
12 | "type": "git",
13 | "url": "git://github.com/spatools/grunt-nuget.git"
14 | },
15 | "bugs": {
16 | "url": "https://github.com/spatools/grunt-nuget/issues"
17 | },
18 | "scripts": {
19 | "test": "grunt"
20 | },
21 | "devDependencies": {
22 | "grunt": "^1.0.1",
23 | "grunt-contrib-clean": "^1.0.0"
24 | },
25 | "keywords": [
26 | "gruntplugin",
27 | "grunt",
28 | "nuget",
29 | "package",
30 | "pack",
31 | "spec",
32 | "update",
33 | "restore",
34 | "publish",
35 | "gallery"
36 | ]
37 | }
38 |
--------------------------------------------------------------------------------
/tasks/nuget-key.js:
--------------------------------------------------------------------------------
1 | /*
2 | * grunt-nuget
3 | * https://github.com/spatools/grunt-nuget
4 | * Copyright (c) 2013 SPA Tools
5 | * Code below is licensed under MIT License
6 | *
7 | * Permission is hereby granted, free of charge, to any person
8 | * obtaining a copy of this software and associated documentation
9 | * files (the "Software"), to deal in the Software without restriction,
10 | * including without limitation the rights to use, copy, modify, merge,
11 | * publish, distribute, sublicense, and/or sell copies of the Software,
12 | * and to permit persons to whom the Software is furnished to do so,
13 | * subject to the following conditions:
14 | *
15 | * The above copyright notice and this permission notice shall be
16 | * included in all copies or substantial portions of the Software.
17 | *
18 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
19 | * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES
20 | * OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
21 | * IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR
22 | * ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF
23 | * CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
24 | * WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
25 | */
26 |
27 | module.exports = function (grunt) {
28 | var _ = grunt.util._,
29 | async = grunt.util.async,
30 | nuget = require("../libs/nuget")(grunt);
31 |
32 | grunt.registerTask('nugetkey', "NuGet Set API Key - Set globally API Key for specified server or NuGet Gallery", function () {
33 | var done = this.async(),
34 | key = grunt.option("key"),
35 | source = grunt.option("source"),
36 | args = {};
37 |
38 | if (!key) {
39 | grunt.log.error().error("No key provided, please provide a key by adding --key arguments to console");
40 | done(false);
41 | return;
42 | }
43 |
44 | if (source) {
45 | args.source = source;
46 | }
47 |
48 | nuget.setapikey(key, args, function (err) {
49 | if (err) {
50 | grunt.log.error().error(err);
51 | done(false);
52 | return;
53 | }
54 |
55 | grunt.log.ok("NuGet API Key successfully stored !");
56 | done();
57 | });
58 | });
59 | };
60 |
--------------------------------------------------------------------------------
/tasks/nuget-pack.js:
--------------------------------------------------------------------------------
1 | /*
2 | * grunt-nuget
3 | * https://github.com/spatools/grunt-nuget
4 | * Copyright (c) 2013 SPA Tools
5 | * Code below is licensed under MIT License
6 | *
7 | * Permission is hereby granted, free of charge, to any person
8 | * obtaining a copy of this software and associated documentation
9 | * files (the "Software"), to deal in the Software without restriction,
10 | * including without limitation the rights to use, copy, modify, merge,
11 | * publish, distribute, sublicense, and/or sell copies of the Software,
12 | * and to permit persons to whom the Software is furnished to do so,
13 | * subject to the following conditions:
14 | *
15 | * The above copyright notice and this permission notice shall be
16 | * included in all copies or substantial portions of the Software.
17 | *
18 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
19 | * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES
20 | * OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
21 | * IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR
22 | * ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF
23 | * CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
24 | * WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
25 | */
26 |
27 | module.exports = function (grunt) {
28 | var _ = grunt.util._,
29 | async = grunt.util.async,
30 | nuget = require("../libs/nuget")(grunt);
31 |
32 | grunt.registerMultiTask('nugetpack', "NuGet Pack - Create NuGet package", function () {
33 | var params = this.options(),
34 | done = this.async();
35 |
36 | async.forEach(
37 | this.files,
38 | function (file, callback) {
39 | var dest = file.dest || "";
40 |
41 | async.forEach(
42 | file.src,
43 | function (src, complete) {
44 | grunt.file.mkdir(dest);
45 | nuget.pack(src, _.extend(params, { outputDirectory: dest }), complete);
46 | },
47 | callback
48 | );
49 | },
50 | function (err) {
51 | if (err) {
52 | grunt.log.error().error(err);
53 | done(false);
54 | return;
55 | }
56 |
57 | grunt.log.ok("NuGet Packages created !");
58 | done();
59 | }
60 | );
61 | });
62 | };
63 |
--------------------------------------------------------------------------------
/tasks/nuget-push.js:
--------------------------------------------------------------------------------
1 | /*
2 | * grunt-nuget
3 | * https://github.com/spatools/grunt-nuget
4 | * Copyright (c) 2013 SPA Tools
5 | * Code below is licensed under MIT License
6 | *
7 | * Permission is hereby granted, free of charge, to any person
8 | * obtaining a copy of this software and associated documentation
9 | * files (the "Software"), to deal in the Software without restriction,
10 | * including without limitation the rights to use, copy, modify, merge,
11 | * publish, distribute, sublicense, and/or sell copies of the Software,
12 | * and to permit persons to whom the Software is furnished to do so,
13 | * subject to the following conditions:
14 | *
15 | * The above copyright notice and this permission notice shall be
16 | * included in all copies or substantial portions of the Software.
17 | *
18 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
19 | * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES
20 | * OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
21 | * IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR
22 | * ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF
23 | * CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
24 | * WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
25 | */
26 |
27 | module.exports = function (grunt) {
28 | var _ = grunt.util._,
29 | async = grunt.util.async,
30 | nuget = require("../libs/nuget")(grunt);
31 |
32 | grunt.registerMultiTask('nugetpush', "NuGet Push - Publish NuGet package", function () {
33 | var done = this.async(),
34 | params = this.options({
35 | source: "https://www.nuget.org/api/v2/package"
36 | });
37 |
38 | async.forEach(
39 | this.files,
40 | function (file, callback) {
41 | var dest = file.dest || "";
42 |
43 | async.forEach(
44 | file.src,
45 | function (src, complete) {
46 | nuget.push(src, params, complete);
47 | },
48 | callback
49 | );
50 | },
51 | function (err) {
52 | if (err) {
53 | grunt.log.error().error(err);
54 | done(false);
55 | return;
56 | }
57 |
58 | grunt.log.ok("NuGet Packages published !");
59 | done();
60 | }
61 | );
62 | });
63 | };
64 |
--------------------------------------------------------------------------------
/tasks/nuget-restore.js:
--------------------------------------------------------------------------------
1 | /*
2 | * grunt-nuget
3 | * https://github.com/spatools/grunt-nuget
4 | * Copyright (c) 2013 SPA Tools
5 | * Code below is licensed under MIT License
6 | *
7 | * Permission is hereby granted, free of charge, to any person
8 | * obtaining a copy of this software and associated documentation
9 | * files (the "Software"), to deal in the Software without restriction,
10 | * including without limitation the rights to use, copy, modify, merge,
11 | * publish, distribute, sublicense, and/or sell copies of the Software,
12 | * and to permit persons to whom the Software is furnished to do so,
13 | * subject to the following conditions:
14 | *
15 | * The above copyright notice and this permission notice shall be
16 | * included in all copies or substantial portions of the Software.
17 | *
18 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
19 | * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES
20 | * OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
21 | * IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR
22 | * ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF
23 | * CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
24 | * WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
25 | */
26 |
27 | module.exports = function (grunt) {
28 | var _ = grunt.util._,
29 | async = grunt.util.async,
30 | nuget = require("../libs/nuget")(grunt);
31 |
32 | grunt.registerMultiTask('nugetrestore', "NuGet Restore - Restore NuGet packages", function () {
33 | var params = this.options(),
34 | done = this.async();
35 |
36 | async.forEach(
37 | this.files,
38 | function (file, callback) {
39 | var dest = file.dest || "";
40 |
41 | async.forEach(
42 | file.src,
43 | function (src, complete) {
44 | nuget.restore(src, _.extend(params, { packagesDirectory: dest }), complete);
45 | },
46 | callback
47 | );
48 | },
49 | function (err) {
50 | if (err) {
51 | grunt.log.error().error(err);
52 | done(false);
53 | return;
54 | }
55 |
56 | grunt.log.ok("NuGet Packages restored !");
57 | done();
58 | }
59 | );
60 | });
61 | };
62 |
--------------------------------------------------------------------------------
/tasks/nuget-update.js:
--------------------------------------------------------------------------------
1 | /*
2 | * grunt-nuget
3 | * https://github.com/spatools/grunt-nuget
4 | * Copyright (c) 2013 SPA Tools
5 | * Code below is licensed under MIT License
6 | *
7 | * Permission is hereby granted, free of charge, to any person
8 | * obtaining a copy of this software and associated documentation
9 | * files (the "Software"), to deal in the Software without restriction,
10 | * including without limitation the rights to use, copy, modify, merge,
11 | * publish, distribute, sublicense, and/or sell copies of the Software,
12 | * and to permit persons to whom the Software is furnished to do so,
13 | * subject to the following conditions:
14 | *
15 | * The above copyright notice and this permission notice shall be
16 | * included in all copies or substantial portions of the Software.
17 | *
18 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
19 | * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES
20 | * OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
21 | * IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR
22 | * ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF
23 | * CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
24 | * WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
25 | */
26 |
27 | module.exports = function (grunt) {
28 | var _ = grunt.util._,
29 | async = grunt.util.async,
30 | nuget = require("../libs/nuget")(grunt);
31 |
32 | grunt.registerMultiTask('nugetupdate', "NuGet Update - Update NuGet packages", function () {
33 | var params = this.options(),
34 | done = this.async();
35 |
36 | async.forEach(
37 | this.files,
38 | function (file, callback) {
39 | async.forEach(
40 | file.src,
41 | function (src, complete) {
42 | nuget.update(src, params, complete);
43 | },
44 | callback
45 | );
46 | },
47 | function (err) {
48 | if (err) {
49 | grunt.log.error().error(err);
50 | done(false);
51 | return;
52 | }
53 |
54 | grunt.log.ok("NuGet Packages update !");
55 | done();
56 | }
57 | );
58 | });
59 | };
60 |
--------------------------------------------------------------------------------
/tests/Package.nuspec:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 | PackageTest
5 | 1.0.0
6 | SPA Tools
7 | SPA Tools
8 | https://github.com/spatools/grunt-nuget/LICENSE
9 | https://github.com/spatools/grunt-nuget
10 | https://github.com/spatools/grunt-nuget
11 | false
12 | PackageTest description
13 | Changes of Test Packages
14 | Copyright SPA Tools 2013
15 | Test Package Grunt NuGet Packer
16 |
17 |
18 |
19 |
20 |
21 |
22 |
--------------------------------------------------------------------------------
/tests/packages.config:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
--------------------------------------------------------------------------------