问题描述
我有一个 asp.net web 应用程序,我在进行更改或修复错误时将其发布到我们的网站.我们想自动将项目文件的备份保存到百家乐凯发k8的服务器(与 svn 签入分开),所以我编写了一个批处理文件将整个项目从我的本地驱动器复制到服务器.单独运行时批处理文件可以正常工作,所以这不是问题.如果这是一个问题,批处理文件不在项目的路径中.
i've got an asp.net web app that i publish to our website when i make changes or fix bugs. we want to automatically save a backup of the project files to our server (separate from the svn check in), so i wrote a batch file to copy the entire project from my local drive to the server. the batch file works properly when run stand alone, so that's not the problem. the batch file is not in the path of the project if that's a concern.
然后我将这些行添加到我的 .csproj 文件中,就在结束 标记的正上方:
then i added these lines to my .csproj file right above the closing tag:
这遵循 用于覆盖目标的 msdn.
我也尝试过 这个 so question.看起来像这样:
i have also tried the method outlined in this so question. which looked like this:
这也不行.
为了完整起见,这里是批处理文件,它非常简单,但如果有人感兴趣,我可以解释一下开关:
for completeness, here's the batch file, it's pretty simple, but i can explain the switches if anyone's interested:
xcopy c:degasp.netonlinerma_singlepage*.* /cherkydi i:commonappdevbranchservicema
我使用 build > publish rma 在 vs2010 中发布,效果很好.只是备份脚本永远不会运行.唯一的共同点是脚本本身.我见过其他使用从源目录到目标目录的副本的示例,但我想我明白你可以通过 exec 命令调用外部脚本?这是我为该方法找到的示例 so 问题.
i publish in vs2010 using build > publish rma, which works fine. it's just the backup script never runs. the only commonality is the script itself. i've seen other examples that use a copy from source dir to destination dir, but i thought i understood that you could just call an external script through the exec command? here's the example so question i found for that method.
我确定我遗漏了一些明显的东西,但是我已经进入第二天的事情了,看起来很简单,所以我遗漏了什么?
i'm certain i'm missing something obvious, but i'm onto my second day of messing around with something that seems pretty straight forward, so what am i missing?
推荐答案
我看到一位 ms 开发人员的评论指出,发布到文件系统"不会调用 msdeploypublish 目标.你可以在这里看到.
i saw a comment from a ms developer stating that publishing that goes to the 'file system' does not call msdeploypublish target. you can see that here.
https://social.msdn.microsoft.com/forums/vstudio/en-us/60b196e9-28e1-4d9d-b464-d57e42353754/vs2012-afterpublish-for-web-application?forum=msbuild
http://sedodream.com/permalink,guid,b352f04a-2449-4cbb-8125-7acdef9552e1.aspx
在 *.targets 文件中四处挖掘,我可以在 aftertargets 属性中放置一些目标,这些目标在发布复制到 临时 obj 输出文件夹后完成运行.我永远找不到在复制到发布配置文件中定义的实际文件夹后运行的文件.
digging around in the *.targets files there were a few targets i could place in the aftertargets attribute that accomplished running after the publish had copied to the temporary obj output folder. i could never find one that ran after copying to the actual folder defined in the publish profile.
这是我认为您需要的:
我不确定您要备份什么 - 原始来源或已发布的来源.在执行此操作时,如果您需要已发布文件"的路径,您可以通过 $(webprojectoutputdir)$(wppallfilesinsinglefolder) 将参数传递给您的脚本.这类似于 c:{path to *.csproj}obj{build configuration}packagepackagetmp.
i'm not sure what you are backing up though - the original source or the published source. at the time of this exec, if you need the path to the 'published files', you can pass in a parameter to your script via $(webprojectoutputdir)$(wppallfilesinsinglefolder). this would be something like c:{path to *.csproj}obj{build configuration}packagepackagetmp.