做新项目,当时参考NopCommerce的结构,后台Nop.Admin是一个独立的Area Web Site,但部署的时候发现,使用一键发布,Admin Area会丢失。
研究了下NopCommerce的做法,使用MSBuild组织文件结构,关键的地方在下面:
<!--Now lets publish Nop.Admin-->
<MSBuild Projects="$(RootFolder)\Presentation\Nop.Web\Administration\Nop.Admin.csproj"
Targets="ResolveReferences;_CopyWebApplication"
Properties="WebProjectOutputDir=$(DeployFolder)\$(DeployPrefix)\Administration\;
OutDir=$(DeployFolder)\$(DeployPrefix)\Administration\bin\;Configuration=$(Configuration)" />
<!--Now lets move the Nop.Admin/bin/ to the root bin/-->
<CreateItem Include="$(DeployFolder)\$(DeployPrefix)\Administration\bin\*.dll">
<Output TaskParameter="Include" ItemName="CompileOutput" />
</CreateItem>
<Copy SourceFiles="@(CompileOutput)"
DestinationFolder="$(DeployFolder)\$(DeployPrefix)\bin\" />
<!--Lets delete the bin in Nop.Admin-->
<RemoveDir Directories="$(DeployFolder)\$(DeployPrefix)\Administration\bin\" />
<!--Lets delete the packages.config files-->
<Delete Files="$(DeployFolder)\$(DeployPrefix)\Administration\packages.config;
$(DeployFolder)\$(DeployPrefix)\packages.config"/>
MSBuild参考资料:http://technet.microsoft.com/zh-cn/library/0k6kkbsd