使用 MSBuild/MSDeploy 进行部署时如何跳过某些文件(或者应该?)?
我正在使用此命令来构建和部署我的网站:
MSBuild myprj.sln
/P:Configuration=Debug
/P:DeployOnBuild=True
/P:MsDeployServiceUrl=http://myserver/MsDeployAgentService
/P:MSDeployPublishMethod=RemoteAgent
/P:DeployTarget=MSDeployPublish
/P:UserName=foo
/P:Password=bar
/P:DeployIisAppPath="Default Web Site\MyApp"
它效果很好,但我想排除某个数据文件,例如 ~/App_Data/data.xml
。我不希望在我的项目中使用 data.xml
,因为它是由应用程序生成或由用户设置的(例如,通过将 data.xml.orig
重命名和配置为 data.xml
)。
那么该怎么办呢?我可以简单地将其从 MSDeploy 中排除还是应该以其他方式处理?
I'm using this command to build and deploy my site:
MSBuild myprj.sln
/P:Configuration=Debug
/P:DeployOnBuild=True
/P:MsDeployServiceUrl=http://myserver/MsDeployAgentService
/P:MSDeployPublishMethod=RemoteAgent
/P:DeployTarget=MSDeployPublish
/P:UserName=foo
/P:Password=bar
/P:DeployIisAppPath="Default Web Site\MyApp"
It works great, except I think I want to exclude a certain data file, say, ~/App_Data/data.xml
. I don't want data.xml
in my project since it's generated by the app or setup by the user (e.g. by renaming and configuring data.xml.orig
to data.xml
).
So what to do? Can I simply exclude it from MSDeploy or should I be handling this another way?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
发布的文件是项目的构建输出;这包括您的 DLL 以及“构建操作”设置为“内容”的任何文件。如果将“构建操作”设置为“无”(在 VS 中单击该文件,查看其属性),它应该会自动排除。
如果您想完全排除 App_Data 文件夹的内容,可以在项目属性的“打包/发布 Web”选项卡上找到一个选项。
The files that get published are the build outputs from your project; this includes your DLL and any files with Build Action set to Content. If you set the Build Action to None (click the file in VS, view it's properties), it should get excluded automatically.
If you want to exclude the contents of the App_Data folder entirely, there's an option in the project properties, on the Package/Publish Web tab.
如果我没猜错的话,您应该将 /p:SkipExtraFilesOnServer=True 添加到命令行中。
这会将所有额外的文件留在目的地,这在某些情况下可能是一个缺陷,
如果您只想跳过某些文件夹(如果您不想让服务器产生大量垃圾,同时仍保持某些文件夹完好无损,则可能需要这样做) - 你可以使用这个问题的解决方案:
将 MSBuild PublishProfile 与 Visual Studio 结合使用时的 MSDeploy 跳过规则2012
If I got you right, you should add /p:SkipExtraFilesOnServer=True to your command line.
This would leave all extra files on destination, which could be a flaw in some scenarios
If you want to skip only some folders (which could be required, if you do not want to garbage your server a lot, while still keeping some folders intact) - you could use solution from this question:
MSDeploy skip rules when using MSBuild PublishProfile with Visual Studio 2012