Created
October 11, 2016 22:51
-
-
Save DontPanic345/b049a36241d21423fadefeaae80f8269 to your computer and use it in GitHub Desktop.
Update C# and VB project files to only copy files to the output if the file has changed
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
My C# and VB.net project files contain many lines | |
<CopyToOutputDirectory>Always</CopyToOutputDirectory> | |
and I want them to say | |
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory> | |
so the gist of it is | |
find -regex '.*\.vbproj\|.*\.csproj' -exec sed --in-place --binary 's:<CopyToOutputDirectory>Always</CopyToOutputDirectory>:<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>:' {} \; | |
Explaination: | |
find Finds files | |
-regex search by expression, this isn't the same regex as grep tho so watch out! | |
-exec will execute the given command with {} substituted with each of the file names | |
\; ends the -exec command with substituting one file name at a time | |
sed Steam EDitor | |
--in-place edit the files inplace (makes a backup if suffix supplied) | |
--binary Using Mingw on windows so this flag is required to corretly handle the end of line characters | |
s:old:new: substitue command |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment