Last active
March 28, 2020 09:44
-
-
Save dtwk2/b52d7236ecdd2fd6c2f0b06709c7f99f to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Best solution (to copy to .csproj file) | |
- Runs after packing | |
- RoboCopy needs space after path arg e.g "..\df sd " if path has spaces in it otherwise do not include space. | |
- /XO ignores newer files in source | |
- /NFL /NDL /NJH partially removes RoboCopy output | |
- Since RoboCopy had different exit codes than MSBuild and many don't indicate error; need last two lines | |
<Target Name="PostPack" AfterTargets="Pack"> | |
<Exec Command=" | |
set source="$(ProjectDir)$(OutDir).. "
 | |
set target="..\NugetPackages " 
 | |
RoboCopy %25source%25 %25target%25 *.nupkg /XO /NFL /NDL /NJH 
 | |
IF %ERRORLEVEL% GEQ 8 exit 1
 | |
exit 0" /> | |
</Target> | |
Won't work | |
xcopy will overwrite files if they were generated on different dates | |
dotnet pack --no-build --output nupkgs --include-source --include-symbols | |
set store="<name of nuget package store directory>" | |
for %%f in ("$(ProjectDir)$(OutDir)..\*.nupkg") do xcopy %%f %store% /Y /I /D | |
or alternativaly | |
<Target Name="PostPack" AfterTargets="Pack"> | |
<Exec Command="
set store="<name of nuget package store directory>"
for %25%25f in ("$(ProjectDir)$(OutDir)..\*.nupkg") do xcopy %25%25f %25store%25 /Y /I /D" /> | |
</Target> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
robocopy c:\Sourcepath c:\Destpath /E /XC /XN /XO
:: /E makes Robocopy recursively copy subdirectories, including empty ones.
:: /XC excludes existing files with the same timestamp, but different file sizes. Robocopy normally overwrites those.
:: /XN excludes existing files newer than the copy in the source directory. Robocopy normally overwrites those.
:: /XO excludes existing files older than the copy in the source directory. Robocopy normally overwrites those.
:: With the Changed, Older, and Newer classes excluded, Robocopy will exclude files existing in the destination directory.