我在VS2010中有一个项目,它使用Web安装项目进行部署。我现在正在考虑将其迁移到VS2012,并且必须找到替换设置例程。
我的要求:
我应该从哪里开始?我应该看看VS2012中改进的发布功能吗?我应该看看Wix吗?还有别的吗?
答案 0 :(得分:1)
深入研究Visual Studio 2012并试图按照预期的方式使用它,而不是反对它,我们最终使用了Web部署包。它不会创建MSI文件,而是创建一个可以轻松导入目标计算机上的IIS的zip文件。
Windows服务项目已添加为对网站项目的引用。这样,服务的二进制文件包含在网站的bin目录中。来自实体框架的migrate.exe文件被添加为bin目录中的链接,这意味着它也已部署。
最后,我们向项目添加了一个project.wpp.targets文件,该文件运行所需的命令来安装和启动服务,并获得部署中包含的服务配置文件。这对我们有用,但并不是那么优雅(例如,不同配置的网站安装路径是硬编码的。)
project.wpp.targets文件:
<?xml version="1.0" encoding="utf-8" ?>
<!--
*** WARNING ***
This file is cached by visual studio and changes won't take effect until
visual studio is restarted. When editing this file, it is better to run the
build step for packaging from the command line (a VS command prompt).
There are some problems with dependencies not being correctly identified that
way, but at least the archive.xml file can be verified from the command prompt.
msbuild orderportal.csproj /t:package /p:Configuration=SysTest /p:DeployOnBuild=true;DeployTarget=Package
-->
<Project ToolsVersion="4.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<PropertyGroup>
<IncludeRunMigrations>TRUE</IncludeRunMigrations>
<AfterAddIisSettingAndFileContentsToSourceManifest Condition="'$(AfterAddIisSettingAndFileContentsToSourceManifest)'==''">
$(AfterAddIisSettingAndFileContentsToSourceManifest);
RunMigrations;
ServiceInstall;
</AfterAddIisSettingAndFileContentsToSourceManifest>
<IncludeServiceInstall>TRUE</IncludeServiceInstall>
<BeforeAddContentPathToSourceManifest Condition="'$(BeforeAddContentPathToSourceManifest)' == ''">
$(BeforeAddContentPathToSourceManifest);
ServiceUnInstall;
</BeforeAddContentPathToSourceManifest>
<DeploymentDir Condition="'$(Configuration)'=='SysTest' AND '$(DeploymentDir)'==''">c:\inetpub\wwwroot\SysTest\</DeploymentDir>
<DeploymentDir Condition="'$(Configuration)'=='IntTest' AND '$(DeploymentDir)'==''">c:\inetpub\wwwroot\IntTest\</DeploymentDir>
<DeploymentDir Condition="'$(Configuration)'=='Prod' AND '$(DeploymentDir)'==''">c:\inetpub\wwwroot\</DeploymentDir>
<CopyAllFilesToSingleFolderForPackageDependsOn>
IncludeServicesAppConfig;
$(CopyAllFilesToSingleFolderForPackageDependsOn);
</CopyAllFilesToSingleFolderForPackageDependsOn>
</PropertyGroup>
<Target Name="RunMigrations" Condition="'$(IncludeRunMigrations)' == 'TRUE'">
<Message Text="Adding migration running"/>
<ItemGroup>
<MsDeploySourceManifest Include="runCommand">
<path>$(DeploymentDir)bin\migrate.exe /startupdirectory:$(DeploymentDir)bin Topsi.Core.dll /startUpConfigurationFile:$(DeploymentDir)web.config</path>
<waitAttempts>1</waitAttempts>
<waitInterval>60000</waitInterval>
<dontUseCommandExe>true</dontUseCommandExe>
<AdditionalProviderSettings>waitInterval;waitAttempts;dontUseCommandExe</AdditionalProviderSettings>
</MsDeploySourceManifest>
</ItemGroup>
</Target>
<Target Name="ServiceUnInstall" Condition="'$(IncludeServiceInstall)' == 'TRUE'">
<Message Text="Adding service uninstall" />
<ItemGroup>
<MsDeploySourceManifest Include="runCommand">
<path>net stop "Topsi Schedule Service $(Configuration)"</path>
<waitAttempts>1</waitAttempts>
<waitInterval>60000</waitInterval>
<dontUseCommandExe>true</dontUseCommandExe>
<AdditionalProviderSettings>waitInterval;waitAttempts;dontUseCommandExe</AdditionalProviderSettings>
</MsDeploySourceManifest>
<MsDeploySourceManifest Include="runCommand">
<path>C:\Windows\Microsoft.NET\Framework\v4.0.30319\installutil.exe /u $(DeploymentDir)bin\Topsi.Services.exe</path>
<waitAttempts>1</waitAttempts>
<waitInterval>60000</waitInterval>
<dontUseCommandExe>true</dontUseCommandExe>
<AdditionalProviderSettings>waitInterval;waitAttempts;dontUseCommandExe</AdditionalProviderSettings>
</MsDeploySourceManifest>
</ItemGroup>
</Target>
<Target Name="ServiceInstall" Condition="'$(IncludeServiceInstall)' == 'TRUE'">
<Message Text="Adding service install"/>
<ItemGroup>
<MsDeploySourceManifest Include="runCommand">
<path>C:\Windows\Microsoft.NET\Framework\v4.0.30319\installutil.exe $(DeploymentDir)bin\Topsi.Services.exe</path>
<waitAttempts>1</waitAttempts>
<waitInterval>60000</waitInterval>
<dontUseCommandExe>true</dontUseCommandExe>
<AdditionalProviderSettings>waitInterval;waitAttempts;dontUseCommandExe</AdditionalProviderSettings>
</MsDeploySourceManifest>
<MsDeploySourceManifest Include="runCommand">
<path>net start "Topsi Schedule Service $(Configuration)"</path>
<waitAttempts>1</waitAttempts>
<waitInterval>60000</waitInterval>
<dontUseCommandExe>true</dontUseCommandExe>
<AdditionalProviderSettings>waitInterval;waitAttempts;dontUseCommandExe</AdditionalProviderSettings>
</MsDeploySourceManifest>
</ItemGroup>
</Target>
<Target Name="IncludeServicesAppConfig">
<ItemGroup>
<_CustomFiles Include="..\Services\bin\$(Configuration)\Topsi.Services.exe.config">
<DestinationRelativePath>%(RecursiveDir)%(Filename)%(Extension)</DestinationRelativePath>
</_CustomFiles>
<FilesForPackagingFromProject Include="%(_CustomFiles.Identity)">
<DestinationRelativePath>bin\%(RecursiveDir)%(Filename)%(Extension)</DestinationRelativePath>
</FilesForPackagingFromProject>
</ItemGroup>
</Target>
</Project>