感谢您的回答。我现在修复了所有问题,在为我的数据库(migrator.net)包含构建和迁移方面付出了很多努力,但我作弊并通过运行命令完成了它。
我想我在这里发布我的整个部署过程,这样阅读这篇文章的人可能会从我所有的错误中吸取教训。基本步骤是:
- Web.config 转换以确保每个客户端的所有设置都是正确的
- 在生产服务器上备份网络服务器文件和数据库
- 排除所有客户端的所有 gfx 目录
- 包括这个客户想要的 gfx 目录
- 包括项目 correclty 未引用的额外二进制文件和许可证文件
- 将数据库迁移到当前版本
- 网络部署所有新文件
Deploy.proj,由<Import Project="Deploy.csproj" />
webproject 项目文件的最后一行导入:
<Project xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<PropertyGroup>
<CopyAllFilesToSingleFolderForPackageDependsOn>
ExcludeAllGfx;
Client1Backup;
Client1Include;
Client1Migrate;
CollectBinFiles;
$(CopyAllFilesToSingleFolderForPackageDependsOn);
</CopyAllFilesToSingleFolderForPackageDependsOn>
</PropertyGroup>
<Target Name="ExcludeAllGfx" BeforeTargets="ExcludeFilesFromPackage">
<ItemGroup>
<ExcludeFromPackageFiles Include="gfx\client1\**\*.*">
<FromTarget>Project</FromTarget>
</ExcludeFromPackageFiles>
<ExcludeFromPackageFiles Include="gfx\client2\**\*.*">
<FromTarget>Project</FromTarget>
</ExcludeFromPackageFiles>
<ExcludeFromPackageFiles Include="gfx\client3\**\*.*">
<FromTarget>Project</FromTarget>
</ExcludeFromPackageFiles>
</ItemGroup>
<Message Text="ExcludeFromPackageFiles: @(ExcludeFromPackageFiles)" Importance="high" />
</Target>
<Target Name="CollectBinFiles">
<ItemGroup>
<_CustomFiles Include="..\IncludeBin\Telerik\Telerik.ReportViewer.WebForms.dll" />
<_CustomFiles Include="..\IncludeBin\Telerik\Telerik.Reporting.dll" />
<FilesForPackagingFromProject Include="%(_CustomFiles.Identity)">
<DestinationRelativePath>Bin\%(Filename)%(Extension)</DestinationRelativePath>
</FilesForPackagingFromProject>
</ItemGroup>
</Target>
<Target Name="Client1Migrate" Condition="'$(Configuration)|$(Platform)' == 'Release Client1|AnyCPU'">
<Exec Command=""..\MigratorProject\Bats\Client1.bat"" ContinueOnError="false" />
</Target>
<Target Name="Client1Include" Condition="'$(Configuration)|$(Platform)' == 'Release Client1|AnyCPU'">
<ItemGroup>
<_CustomFilesClient1 Include="gfx\Client1\**\*.*" Exclude="gfx\Client1\**\.svn\**\*.*">
<FromTarget>Project</FromTarget>
</_CustomFilesClient1>
<FilesForPackagingFromProject Include="%(_CustomFilesClient1.Identity)">
<DestinationRelativePath>gfx\client1\%(RecursiveDir)%(Filename)%(Extension)</DestinationRelativePath>
</FilesForPackagingFromProject>
</ItemGroup>
</Target>
<Target Name="Client1Backup" Condition="'$(Configuration)|$(Platform)' == 'Release Client1|AnyCPU'">
<Exec Command=""C:\Program Files\IIS\Microsoft Web Deploy\msdeploy.exe" -verb:sync -source:contentPath="page of client1",computerName=http://10.8.1.1/MsDeployAgentService2,encryptPassword=pass -dest:package=c:\Backups\deployments\client1.zip,computerName=http://10.8.1.1/MsDeployAgentService2,encryptPassword=pass" ContinueOnError="false" />
<Exec Command=""C:\Program Files\IIS\Microsoft Web Deploy\msdeploy.exe" -verb:sync -source:runCommand='C:\Backups\deployments\scripts\backup.cmd client1',waitInterval=20000 -dest:auto,computerName=http://10.8.1.1/MsDeployAgentService2,encryptPassword=pass" ContinueOnError="false" />
</Target>
</Project>
备份.cmd:
@echo off
sqlcmd -v name=%1 -S . -i "C:\Backups\deployments\scripts\backupdb.sql"
C:\Backups\deployments\scripts\stampme "C:\Backups\deployments\%1.zip"
备份数据库.sql:
DECLARE @name NVARCHAR(50) -- database name
DECLARE @path NVARCHAR(256) -- path for backup files
DECLARE @fileName NVARCHAR(256) -- filename for backup
DECLARE @fileDate NVARCHAR(20) -- used for file name
SET @name = '$(name)'
SET @path = 'C:\Backups\deployments\'
SELECT @fileDate = REPLACE(REPLACE(CONVERT(VARCHAR(50),GETDATE(),120),':','-'), ' ', '@')
SET @fileName = @path + @name + '_' + @fileDate + '.BAK'
BACKUP DATABASE @name TO DISK = @fileName;
stampme.bat:http ://ss64.com/nt/syntax-stampme.html
希望任何人都能从这篇文章中得到一些帮助和例子。