项目属性-->生成事件-->后期生成事件命令行

以开源记牌器https://github.com/Epix37/Hearthstone-Deck-Tracker 为例,Hearthstone Deck Tracker项目中的后期生成事件命令行:

 

if "$(ConfigurationName)" == "Release" (
rmdir /S /Q "..\Hearthstone Deck Tracker"
mkdir "..\Hearthstone Deck Tracker"
mkdir "..\Hearthstone Deck Tracker/Images"
mkdir "..\Hearthstone Deck Tracker/Files"
mkdir "..\Hearthstone Deck Tracker/Plugins"
xcopy /E /Y "Images\*.*" "..\Hearthstone Deck Tracker\Images"
xcopy /E /Y "Files\*.*" "..\Hearthstone Deck Tracker\Files"
xcopy /Y "HearthstoneDeckTracker.exe" "..\Hearthstone Deck Tracker"
xcopy /Y "HearthstoneDeckTracker.exe.config" "..\Hearthstone Deck Tracker"
ren "..\Hearthstone Deck Tracker\HearthstoneDeckTracker.exe" "Hearthstone Deck Tracker.exe"                            //重命名,目的是去掉空格
ren "..\Hearthstone Deck Tracker\HearthstoneDeckTracker.exe.config" "Hearthstone Deck Tracker.exe.config"         //重命名,目的是去掉空格
xcopy /Y "HDTHelper.exe" "..\Hearthstone Deck Tracker"
xcopy /Y "HDTUpdate.exe" "..\Hearthstone Deck Tracker"
xcopy /Y "HDTUninstaller.exe" "..\Hearthstone Deck Tracker"
xcopy /Y "HtmlAgilityPack.dll" "..\Hearthstone Deck Tracker"
xcopy /Y "MahApps.Metro.dll" "..\Hearthstone Deck Tracker"
xcopy /Y "Newtonsoft.Json.dll" "..\Hearthstone Deck Tracker"
xcopy /Y "System.Windows.Interactivity.dll" "..\Hearthstone Deck Tracker"
xcopy /Y "Version.xml" "..\Hearthstone Deck Tracker" )

 

rmdir 参数说明

/S 除目录本身外,还将删除指定目录下的所有子目录和文件。用于删除目录树。
/Q 安静模式,带 /S 删除目录树时不要求确认
 
mkdir 创建目录
 

xcopy 参数说明

xcopy /?

Copies files and directory trees.

XCOPY source [destination] [/A | /M] [/D[:date]] [/P] [/S [/E]] [/V] [/W]
[/C] [/I] [/Q] [/F] [/L] [/G] [/H] [/R] [/T] [/U]
[/K] [/N] [/O] [/X] [/Y] [/-Y] [/Z] [/B] [/J]
[/EXCLUDE:file1[+file2][+file3]...]

source Specifies the file(s) to copy.
destination Specifies the location and/or name of new files.
/A Copies only files with the archive attribute set,
doesn't change the attribute.
/M Copies only files with the archive attribute set,
turns off the archive attribute.
/D:m-d-y Copies files changed on or after the specified date.
If no date is given, copies only those files whose
source time is newer than the destination time.
/EXCLUDE:file1[+file2][+file3]...
Specifies a list of files containing strings. Each string
should be in a separate line in the files. When any of the
strings match any part of the absolute path of the file to be
copied, that file will be excluded from being copied. For
example, specifying a string like \obj\ or .obj will exclude
all files underneath the directory obj or all files with the
.obj extension respectively.
/P Prompts you before creating each destination file.
/S Copies directories and subdirectories except empty ones.
/E Copies directories and subdirectories, including empty ones.
Same as /S /E. May be used to modify /T.
/V Verifies the size of each new file.
/W Prompts you to press a key before copying.
/C Continues copying even if errors occur.
/I If destination does not exist and copying more than one file,
assumes that destination must be a directory.
/Q Does not display file names while copying.
/F Displays full source and destination file names while copying.
/L Displays files that would be copied.
/G Allows the copying of encrypted files to destination that does
not support encryption.
/H Copies hidden and system files also.
/R Overwrites read-only files.
/T Creates directory structure, but does not copy files. Does not
include empty directories or subdirectories. /T /E includes
empty directories and subdirectories.
/U Copies only files that already exist in destination.
/K Copies attributes. Normal Xcopy will reset read-only attributes.
/N Copies using the generated short names.
/O Copies file ownership and ACL information.
/X Copies file audit settings (implies /O).
/Y Suppresses prompting to confirm you want to overwrite an
existing destination file.
/-Y Causes prompting to confirm you want to overwrite an
existing destination file.
/Z Copies networked files in restartable mode.
/B Copies the Symbolic Link itself versus the target of the link.
/J Copies using unbuffered I/O. Recommended for very large files.

The switch /Y may be preset in the COPYCMD environment variable.
This may be overridden with /-Y on the command line.

https://docs.microsoft.com/en-us/windows-server/administration/windows-commands/xcopy

/E 复制目录和子目录,包括空的。与 /S /E 相同。可以用来修改 /T。
Copies all subdirectories, even if they are empty. Use /e with the /s and /t command-line options.
 
/S 复制目录和子目录,除了空的。
Copies directories and subdirectories, unless they are empty. If you omit /s, xcopy works within a single directory.
 
/T 创建目录结构,但不复制文件。不包括空目录或子目录。/T /E 包括空目录和子目录。
Copies the subdirectory structure (that is, the tree) only, not files. To copy empty directories, you must include the /e command-line option.
 
/Y 复制文件审核设置(隐含 /O)。现存目标文件。【就是直接覆盖——Three~注】             这个似乎更准确: 禁止提示以确认改写一个现存目标文件。
Suppresses prompting to confirm that you want to overwrite an existing destination file.
 
/D:m-d-y 复制在指定日期或指定日期以后更改的文件。如果没有提供日期,只复制那些源时间比目标时间新的文件。
/d [:MM-DD-YYYY]
Copies source files changed on or after the specified date only. If you do not include a MM-DD-YYYY value, xcopy copies all Source files that are newer than existing Destination files. This command-line option allows you to update files that have changed.
 

ren是rename的缩写,如果需要给文件重命名,可使用rename命令。

语法:rename<旧文件名><新文件名>
 
 
 
 
=======================

rmdir /S /Q "..\IntelligentBuilding"
mkdir "..\IntelligentBuilding"
xcopy /Y "AxInterop.SliderExLib.dll" "..\IntelligentBuilding"
xcopy /Y "ClientApp.exe" "..\IntelligentBuilding"
xcopy /Y "ClientApp.exe.config" "..\IntelligentBuilding"
xcopy /Y "DevExpress.BonusSkins.v16.1.dll" "..\IntelligentBuilding"
xcopy /Y "DevExpress.Charts.v16.1.Core.dll" "..\IntelligentBuilding"
xcopy /Y "DevExpress.Data.v16.1.dll" "..\IntelligentBuilding"
xcopy /Y "DevExpress.Office.v16.1.Core.dll" "..\IntelligentBuilding"
xcopy /Y "DevExpress.Pdf.v16.1.Core.dll" "..\IntelligentBuilding"
xcopy /Y "DevExpress.Pdf.v16.1.Drawing.dll" "..\IntelligentBuilding"
xcopy /Y "DevExpress.Printing.v16.1.Core.dll" "..\IntelligentBuilding"
xcopy /Y "DevExpress.RichEdit.v16.1.Core.dll" "..\IntelligentBuilding"
xcopy /Y "DevExpress.Sparkline.v16.1.Core.dll" "..\IntelligentBuilding"
xcopy /Y "DevExpress.Utils.v16.1.UI.dll" "..\IntelligentBuilding"
xcopy /Y "DevExpress.Utils.v16.1.dll" "..\IntelligentBuilding"
xcopy /Y "DevExpress.XtraBars.v16.1.dll" "..\IntelligentBuilding"
xcopy /Y "DevExpress.XtraCharts.v16.1.UI.dll" "..\IntelligentBuilding"
xcopy /Y "DevExpress.XtraCharts.v16.1.Wizard.dll" "..\IntelligentBuilding"
xcopy /Y "DevExpress.XtraCharts.v16.1.dll" "..\IntelligentBuilding"
xcopy /Y "DevExpress.XtraEditors.v16.1.dll" "..\IntelligentBuilding"
xcopy /Y "DevExpress.XtraGauges.v16.1.Core.dll" "..\IntelligentBuilding"
xcopy /Y "DevExpress.XtraGauges.v16.1.Win.dll" "..\IntelligentBuilding"
xcopy /Y "DevExpress.XtraGrid.v16.1.dll" "..\IntelligentBuilding"
xcopy /Y "DevExpress.XtraLayout.v16.1.dll" "..\IntelligentBuilding"
xcopy /Y "DevExpress.XtraNavBar.v16.1.dll" "..\IntelligentBuilding"
xcopy /Y "DevExpress.XtraPrinting.v16.1.dll" "..\IntelligentBuilding"
xcopy /Y "DevExpress.XtraRichEdit.v16.1.dll" "..\IntelligentBuilding"
xcopy /Y "DevExpress.XtraTreeList.v16.1.dll" "..\IntelligentBuilding"
xcopy /Y "DevExpress.XtraVerticalGrid.v16.1.dll" "..\IntelligentBuilding"
xcopy /Y "Interop.SliderExLib.dll" "..\IntelligentBuilding"
xcopy /Y "log4net.dll" "..\IntelligentBuilding"

 

实战

现在有一个hotfix文件夹,5.1.0.0 Hotfix。在这个文件夹下有2个子文件夹

hotfix_5.1.1_Generic_20180911  这个子文件夹下有一些module文件夹

hotfix_5.1.2_Generic_20180912   这个子文件夹是新创建的,现在需要把上面的子文件夹的folder复制到这个子文件夹

在hotfix_5.1.1_Generic_20180911文件夹中执行命令

 xcopy /t . ..\hotfix_5.1.2_Generic_20180912\

xcopy /t . '..\..\5.1.0.0 Hotfix\hotfix_5.1.2_Generic_20180912\'  这个命令执行失败,提示说,创建目录失败。

 

谷歌查询之后,发现可以通过powershell的copy-item命令来操作

https://stackoverflow.com/questions/44678962/how-to-copy-folder-structure-only-with-powershell

 

 

 

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值