1dotnet publish command - .NET Core C.LNIEd(To1t)Cnoertepublish command - .NET Core CLI(1)
2
3
4
7 dotnet publish - Packs the application and its dependencies into a
8 folder for deployment to a hosting system.
9
11 .NET Core 2.1
12 dotnet publish [<PROJECT>] [-c|--configuration] [-f|--framework] [--force] [--manifest] [--no-build] [--no-dependencies]
13 [--no-restore] [-o|--output] [-r|--runtime] [--self-contained] [-v|--verbosity] [--version-suffix]
14 dotnet publish [-h|--help]
15
16 .NET Core 2.0
17 dotnet publish [<PROJECT>] [-c|--configuration] [-f|--framework] [--force] [--manifest] [--no-dependencies]
18 [--no-restore] [-o|--output] [-r|--runtime] [--self-contained] [-v|--verbosity] [--version-suffix]
19 dotnet publish [-h|--help]
20
21 .NET Core 1.x
22 dotnet publish [<PROJECT>] [-c|--configuration] [-f|--framework] [-o|--output] [-r|--runtime] [-v|--verbosity]
23 [--version-suffix]
24 dotnet publish [-h|--help]
25
26 * * * * *
27
29 dotnet publish compiles the application, reads through its dependencies
30 specified in the project file, and publishes the resulting set of files
31 to a directory. The output includes the following assets:
32
33 · Intermediate Language (IL) code in an assembly with a dll extension.
34
35 · .deps.json file that includes all of the dependencies of the project.
36
37 · .runtime.config.json file that specifies the shared runtime that the
38 application expects, as well as other configuration options for the
39 runtime (for example, garbage collection type).
40
41 · The application's dependencies, which are copied from the NuGet cache
42 into the output folder.
43
44 The dotnet publish command's output is ready for deployment to a host‐
45 ing system (for example, a server, PC, Mac, laptop) for execution.
46 It's the only officially supported way to prepare the application for
47 deployment. Depending on the type of deployment that the project spec‐
48 ifies, the hosting system may or may not have the .NET Core shared run‐
49 time installed on it. For more information, see .NET Core Application
50 Deployment. For the directory structure of a published application,
51 see Directory structure.
52
53 Arguments
54 PROJECT
55
56 The project to publish. If not specified, it defaults to the current
57 directory.
58
60 .NET Core 2.1
61 -c|--configuration {Debug|Release}
62
63 Defines the build configuration. The default value is Debug.
64
65 -f|--framework <FRAMEWORK>
66
67 Publishes the application for the specified target framework. You must
68 specify the target framework in the project file.
69
70 --force
71
72 Forces all dependencies to be resolved even if the last restore was
73 successful. Specifying this flag is the same as deleting the
74 project.assets.json file.
75
76 -h|--help
77
78 Prints out a short help for the command.
79
80 --manifest <PATH_TO_MANIFEST_FILE>
81
82 Specifies one or several target manifests to use to trim the set of
83 packages published with the app. The manifest file is part of the out‐
84 put of the dotnet store. To specify multiple manifests, add a --mani‐
85 fest option for each manifest. This option is available starting with
86 .NET Core 2.0 SDK.
87
88 --no-build
89
90 Doesn't build the project before publishing. It also implicit sets the
91 --no-restore flag.
92
93 --no-dependencies
94
95 Ignores project-to-project references and only restores the root
96 project.
97
98 --no-restore
99
100 Doesn't execute an implicit restore when running the command.
101
102 -o|--output <OUTPUT_DIRECTORY>
103
104 Specifies the path for the output directory. If not specified, it de‐
105 faults to ./bin/[configuration]/[framework]/publish/ for a frame‐
106 work-dependent deployment or ./bin/[configuration]/[framework]/[run‐
107 time]/publish/ for a self-contained deployment. If the path is rela‐
108 tive, the output directory generated is relative to the project file
109 location, not to the current working directory.
110
111 --self-contained
112
113 Publishes the .NET Core runtime with your application so the runtime
114 doesn't need to be installed on the target machine. If a runtime iden‐
115 tifier is specified, its default value is true. For more information
116 about the different deployment types, see .NET Core application deploy‐
117 ment.
118
119 -r|--runtime <RUNTIME_IDENTIFIER>
120
121 Publishes the application for a given runtime. This is used when cre‐
122 ating a self-contained deployment (SCD). For a list of Runtime Identi‐
123 fiers (RIDs), see the RID catalog. Default is to publish a frame‐
124 work-dependent deployment (FDD).
125
126 -v|--verbosity <LEVEL>
127
128 Sets the verbosity level of the command. Allowed values are q[uiet],
129 m[inimal], n[ormal], d[etailed], and diag[nostic].
130
131 --version-suffix <VERSION_SUFFIX>
132
133 Defines the version suffix to replace the asterisk (*) in the version
134 field of the project file.
135
136 .NET Core 2.0
137 -c|--configuration {Debug|Release}
138
139 Defines the build configuration. The default value is Debug.
140
141 -f|--framework <FRAMEWORK>
142
143 Publishes the application for the specified target framework. You must
144 specify the target framework in the project file.
145
146 --force
147
148 Forces all dependencies to be resolved even if the last restore was
149 successful. Specifying this flag is the same as deleting the
150 project.assets.json file.
151
152 -h|--help
153
154 Prints out a short help for the command.
155
156 --manifest <PATH_TO_MANIFEST_FILE>
157
158 Specifies one or several target manifests to use to trim the set of
159 packages published with the app. The manifest file is part of the out‐
160 put of the dotnet store. To specify multiple manifests, add a --mani‐
161 fest option for each manifest. This option is available starting with
162 .NET Core 2.0 SDK.
163
164 --no-dependencies
165
166 Ignores project-to-project references and only restores the root
167 project.
168
169 --no-restore
170
171 Doesn't execute an implicit restore when running the command.
172
173 -o|--output <OUTPUT_DIRECTORY>
174
175 Specifies the path for the output directory. If not specified, it de‐
176 faults to ./bin/[configuration]/[framework]/publish/ for a frame‐
177 work-dependent deployment or ./bin/[configuration]/[framework]/[run‐
178 time]/publish/ for a self-contained deployment. If the path is rela‐
179 tive, the output directory generated is relative to the project file
180 location, not to the current working directory.
181
182 --self-contained
183
184 Publishes the .NET Core runtime with your application so the runtime
185 doesn't need to be installed on the target machine. If a runtime iden‐
186 tifier is specified, its default value is true. For more information
187 about the different deployment types, see .NET Core application deploy‐
188 ment.
189
190 -r|--runtime <RUNTIME_IDENTIFIER>
191
192 Publishes the application for a given runtime. This is used when cre‐
193 ating a self-contained deployment (SCD). For a list of Runtime Identi‐
194 fiers (RIDs), see the RID catalog. Default is to publish a frame‐
195 work-dependent deployment (FDD).
196
197 -v|--verbosity <LEVEL>
198
199 Sets the verbosity level of the command. Allowed values are q[uiet],
200 m[inimal], n[ormal], d[etailed], and diag[nostic].
201
202 --version-suffix <VERSION_SUFFIX>
203
204 Defines the version suffix to replace the asterisk (*) in the version
205 field of the project file.
206
207 .NET Core 1.x
208 -c|--configuration {Debug|Release}
209
210 Defines the build configuration. The default value is Debug.
211
212 -f|--framework <FRAMEWORK>
213
214 Publishes the application for the specified target framework. You must
215 specify the target framework in the project file.
216
217 -h|--help
218
219 Prints out a short help for the command.
220
221 --manifest <PATH_TO_MANIFEST_FILE>
222
223 Specifies one or several target manifests to use to trim the set of
224 packages published with the app. The manifest file is part of the out‐
225 put of the dotnet store. To specify multiple manifests, add a --mani‐
226 fest option for each manifest. This option is available starting with
227 .NET Core 2.0 SDK.
228
229 -o|--output <OUTPUT_DIRECTORY>
230
231 Specifies the path for the output directory. If not specified, it de‐
232 faults to ./bin/[configuration]/[framework]/publish/ for a frame‐
233 work-dependent deployment or ./bin/[configuration]/[framework]/[run‐
234 time]/publish/ for a self-contained deployment. If the path is rela‐
235 tive, the output directory generated is relative to the project file
236 location, not to the current working directory.
237
238 -r|--runtime <RUNTIME_IDENTIFIER>
239
240 Publishes the application for a given runtime. This is used when cre‐
241 ating a self-contained deployment (SCD). For a list of Runtime Identi‐
242 fiers (RIDs), see the RID catalog. Default is to publish a frame‐
243 work-dependent deployment (FDD).
244
245 -v|--verbosity <LEVEL>
246
247 Sets the verbosity level of the command. Allowed values are q[uiet],
248 m[inimal], n[ormal], d[etailed], and diag[nostic].
249
250 --version-suffix <VERSION_SUFFIX>
251
252 Defines the version suffix to replace the asterisk (*) in the version
253 field of the project file.
254
255 * * * * *
256
258 Publish the project in the current directory:
259
260 dotnet publish
261
262 Publish the application using the specified project file:
263
264 dotnet publish ~/projects/app1/app1.csproj
265
266 Publish the project in the current directory using the netcoreapp1.1
267 framework:
268
269 dotnet publish --framework netcoreapp1.1
270
271 Publish the current application using the netcoreapp1.1 framework and
272 the runtime for OS X 10.10 (you must list this RID in the project
273 file).
274
275 dotnet publish --framework netcoreapp1.1 --runtime osx.10.11-x64
276
277 Publish the current application but don't restore project-to-project
278 (P2P) references, just the root project during the restore operation
279 (.NET Core SDK 2.0 and later versions):
280
281 dotnet publish --no-dependencies
282
283 See also
284 · Target frameworks
285
286 · Runtime IDentifier (RID) catalog
287
289 mairaw.
290
291
292
293 dotnet publish command - .NET Core CLI(1)