Building a ASP.NET solution from command-line?

2019-06-18 18:58发布

How can I build an ASP.NET web application from the command line?

6条回答
Anthone
2楼-- · 2019-06-18 19:09

To build a solution directly,

msbuild mysolution.sln

You'll find MSBuild in the Microsoft.NET folder in your Windows directory.

You may also want to pre-compile your Web site. Instructions for that are on MSDN here. If you use the Web Deployment project node (detailed at the bottom) then the deployment will happen automatically when you run msbuild on the solution file.

查看更多
Rolldiameter
3楼-- · 2019-06-18 19:11

This is a round about way to do it, but you can use the MSBuild task as part of an msbuild project:

<?xml version="1.0" encoding="utf-8"?>
<Project ToolsVersion="3.5" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">

<ItemGroup>
  <Solutions Include="*.sln" />
</ItemGroup>

<Target Name="Build"   >
  <MSBuild BuildInParallel="true" Projects="@(Solutions)" RebaseOutputs="true"  />
</Target>

built with msbuildprojectname.proj from the command line.

This may seem like overkill, but you can then add extra stuff into the project (like restarting websites, zipping files, Virtual machine control even!, code coverage) that can help you setup and test the project.

查看更多
神经病院院长
5楼-- · 2019-06-18 19:18

As dumb as I might look, I have used "aspnet_compiler.exe" for compiling/deploying projects

查看更多
够拽才男人
6楼-- · 2019-06-18 19:26

Try this in a .bat file, replace v4.0.30319 with the appropriate version:

CD C:\Windows\Microsoft.NET\Framework\v4.0.30319 
msbuild "C:\inetpub\wwwroot\MyWebSite.sln"
查看更多
不美不萌又怎样
7楼-- · 2019-06-18 19:29

Take a look at the devenv.exe /Build switch, you give it a solution file to build, e.g.

devenv.exe "C:\Documents and Settings\someuser\MySolution.sln" /build DEBUG

If you have more complex build requirements then look into MSBuild.

查看更多
登录 后发表回答