In project i have as normal files as links (shortcuts) to existing file:
In post-build event i want to copy all files, including links (but as real file) to other directory, for example:
"%RELEASEPATH%\Code\"
Using default xcopy command it do copy all files + directory, but not links:
xcopy /E /Y /R "$(ProjectDir)Code" "%RELEASEPATH%\Code\"
If there a way to copy linked files (as real files) with xcopy as well?
I am not sure of xcopy, but if all you want is for copying the link file to the folder you put the link file in, then you can try:
(source from Copying linked content files at each build using MSBuild)
build by adding the following at the end of the .csproj file, just
before the final tag:
<Target Name="CopyLinkedContentFiles" BeforeTargets="Build">
<Copy SourceFiles="%(Content.Identity)"
DestinationFiles="%(Content.Link)"
SkipUnchangedFiles='true'
OverwriteReadOnlyFiles='true'
Condition="'%(Content.Link)' != ''" />
</Target>
Related
I am a novice. I am trying to copy 1 file into multiple subfolders within windows file explorer. I have successfully copied 1 file into multiple folders within a specified drive using the template below using the CMD prompt.
for /D %a in ("path-to-folder*.*") do xcopy /y /d "Path-to-file\file.FileExt" "%a"
This successfully copies one file to all folders within a specified folder.
Unfortunately I need to copy 1 file into multiple subfolders within a file. I will try to explain as best I can below:
I need an Excel file to copy to all Facility Subfolders within a Facility Folder under Folder1.
File.xls --> Folder 1 --> Facility Folder --> Facility Subfolder
Does that make sense? I need to do this frequently and copy and pasting the excel file to all facility subfolders is time consuming.
Thank you for any assistance!
D
I use this command in order to copy all .ini files (with recursion):
xcopy c:\folder1\folder1A\*.ini c:\mybackup /sy It doesn't copy any file.
There exist desktop.ini files (including comments) within folders and subfolders of folder1A that I want to get a copy of with recursion.
I have tried running CMD as administrator, but it tells 0 File(s) copied. How could I get this to work?
Add the /h option:
/H Copies hidden and system files also. (more info)
This works:
xcopy c:\folder1\folder1A\*.ini c:\mybackup /syh
Thanks to Marged's comment mentioning this question.
I currently have
<PropertyGroup>
<PostBuildEvent>copy "$(TargetPath)" "$(SolutionDir)Shared.Lib\$(TargetFileName)"</PostBuildEvent>
</PropertyGroup>
I want to do something like this, but one level above $(SolutionDir)
You can use ..\ to move up a directory.
<PropertyGroup>
<PostBuildEvent>copy "$(TargetPath)" "$(SolutionDir)..\Shared.Lib\$(TargetFileName)"</PostBuildEvent>
</PropertyGroup>
Solution:
copy "$(TargetPath)" "$(SolutionDir)"..\"Shared.Lib\$(TargetFileName)"
If you have ..\ within the quotation marks, it will take it as literal instead of running the DOS command up one level.
This is not working in VS2010 .. is not resolved but becomes part of the path
Studio is running command something like this copy drive$:\a\b\bin\debug drive$:\a\b..\c
In .Net Core edit csproj file:
<Target Name="PostBuild" AfterTargets="PostBuildEvent">
<Exec Command="copy /Y "$(TargetPath)" "$(SolutionDir)"..\"lib\$(TargetFileName)"" />
</Target>
/Y Suppresses prompting to confirm you want to overwrite an existing destination file.
xcopy "$(TargerDir)." "$(SolutionDir)..\Installer\bin\"
Note: "../" is used for One level up folder structure
I need to copy-paste a folder (files + subfolders) into a BackUpfolder. I also need to append the time into the BackUp folder name. xcopy command is letting me copy only files. Your help would be appreciated.
Source Folder = "C:\Documents and Settings.....\Project" (has many files + subfolders)
Target Folder = "C:\Backup-Date/time of backup" Eg Bacup:May 16 2011 12:30 AM
I plan to run this bat file through Scheduler. Thanks!
XCOPY
Copy files and/or directory trees to another folder. XCOPY is similar to the COPY command except that it has additional switches to specify both the source and destination in detail.
XCOPY is particularly useful when copying files from CDROM to a hard drive, as it will automatically remove the read-only attribute.
Syntax
XCOPY source [destination] [options]
/S Copy folders and subfolders
/E Copy folders and subfolders, including Empty folders.
May be used to modify /T.
/H Copy hidden and system files and folders (default=N)
Key
source : Pathname for the file(s) to be copied.
destination : Pathname for the new file(s).
There are several options you can look at :http://ss64.com/nt/xcopy.html
Soruce: http://ss64.com/nt/xcopy.html
I think reading the documentation of xcopy would go a long way.
I have a DLL project for Visual Studio 2005 that has "XML documetation file" turned on.
Whenever I do an incremental build, during post-build event execution there is no XML documentation file in the output directory.
If I pause the build during post-build event (using sleep utility from GnuWin32 CoreUtils), I can see the file in the output directory with a name like vs5BB5.tmp. But this file is not renamed to MyLib.xml until post-build event (and "AfterBuild" target, as I have some customizations there) are finished.
For a clean build in Studio and for MSBuild started from a command line everything works as expected - XML documentation file is created before post-build events.
Why this happens, and how do I fix incremental builds?
Was just having the same issue. This is a known problem with Visual Studio and incremental builds. See this post on microsoft connect.
I solved it with a conditional xcopy like the one below:
if exist "$(TargetDir)$(TargetName).xml" xcopy $(TargetDir)$(TargetName).xml $(ProjectDir)......\bin\ /C /I /R /Y
SF
Just having this problem myself....
what I found is that the xml file is named a .tmp file, so you can copy this tmp file to where you want, its just a bit of a "messy" work around.
I'm also quite tempted to write myself a command line tool thats called something like :-
WaitForThenCopy <source path> <target path> <milliseconds to wait>
only problem is it would have to be non blocking and you wouldn't know if it worked or not.
I'm using a simple batch file to do the copying instead of the default copy command that detects the tmp file and copies/renames this instead.
REM There is a bug in VS where the xml documentation is written to a tmp file
REM during incremental builds, preventing access during post-build events.
REM See http://connect.microsoft.com/VisualStudio/feedback/details/470485/strange-file-not-found-error-xml-documentation-file-renamed-during-incremental-build
REM As a work around for following script tries to catch this situation and copys/remanes
REM this tmp-file instead.
REM .SYNOPSIS
REM CopyXmlDocumentation "X:\path\to\source.xml" "Y:\target\dir"
if exist "%~1%" (
REM if the file exists, copy it as-is
copy /Y "%~1" "%~2"
) else (
REM else we try to copy the .tmp file and rename it to the desired target name
REM we assume that the tmp file is named "vsXXXX.tmp" where XXXX is an arbitrary string
copy /Y "%~d1\%~p1\vs*.tmp" "%~2\%~n1%~x1"
)