ここの投稿を使用して、MVC5 アプリケーションを IIS 8 に展開しています。IIS には、物理的な場所「C:\Inetpub\wwwroot\mywebsite」を指す Web サイト「既定の Web サイト」があります。
<?xml version="1.0" encoding="utf-8"?>
<Project xmlns="http://schemas.microsoft.com/developer/msbuild/2003" DefaultTargets="Build" ToolsVersion="4.0">
<PropertyGroup>
<Configuration Condition=" '$(Configuration)' == '' ">Release</Configuration>
<ProjectFile Condition=" '$(ProjectFile)' == '' ">.\UI\$(ProjectName)\$(ProjectName).csproj</ProjectFile>
<DeployServiceUrl Condition=" '$(DeployServiceUrl)' == '' ">http://localhost</DeployServiceUrl>
</PropertyGroup>
<Target Name="VerifyProperties">
<!-- Verify that we have values for all required properties -->
<Error Condition=" '$(ProjectName)' == '' " Text="ProjectName is required." />
</Target>
<Target Name="Build" DependsOnTargets="VerifyProperties">
<!-- Deploy using windows authentication -->
<MSBuild Projects="$(ProjectFile)"
Properties="Configuration=$(Configuration);
MvcBuildViews=False;
DeployOnBuild=true;
DeployTarget=MSDeployPublish;
CreatePackageOnPublish=True;
AllowUntrustedCertificate=True;
MSDeployPublishMethod=RemoteAgent;
MsDeployServiceUrl=$(DeployServiceUrl);
SkipExtraFilesOnServer=True;
UserName=;
Password=;"
ContinueOnError="false" />
</Target>
</Project>
次のコマンドを実行してビルドおよびデプロイしています
msbuild build.xml /p:Configuration=Release;ProjectName=MyProjectName;DeployServiceUrl=http://localhost
このコマンドは、プロジェクトをビルドし、プロジェクトをデプロイします。ただし、プロジェクトを「既定の Web サイト」の下に直接展開するのではなく、「既定の Web サイト」の下に「MyProjectName_deploy」という名前の新しいアプリケーションを作成し、このアプリケーションは新しい物理的な場所を指しています。"C:\inetpub\wwwroot\mywebsite\MyProjectName_deploy"
「既定の Web サイト」が指している C:\inetpub\wwwroot\mywebsite にコードを直接展開する必要があります。