项目属性-->生成事件-->后期生成事件命令行
以开源记牌器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 参数说明
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
ren是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
作者:Chuck Lu GitHub |
【推荐】国内首个AI IDE,深度理解中文开发场景,立即下载体验Trae
【推荐】编程新体验,更懂你的AI,立即体验豆包MarsCode编程助手
【推荐】抖音旗下AI助手豆包,你的智能百科全书,全免费不限次数
【推荐】轻量又高性能的 SSH 工具 IShell:AI 加持,快人一步
· 记一次.NET内存居高不下排查解决与启示
· 探究高空视频全景AR技术的实现原理
· 理解Rust引用及其生命周期标识(上)
· 浏览器原生「磁吸」效果!Anchor Positioning 锚点定位神器解析
· 没有源码,如何修改代码逻辑?
· 全程不用写代码,我用AI程序员写了一个飞机大战
· DeepSeek 开源周回顾「GitHub 热点速览」
· MongoDB 8.0这个新功能碉堡了,比商业数据库还牛
· 记一次.NET内存居高不下排查解决与启示
· 白话解读 Dapr 1.15:你的「微服务管家」又秀新绝活了