For my own sanity when trying to move my files to a Unix machine, I need to automatically rename every output file to lowercase.
I currently just rename each of them manually and Windows's compatibility-enforced case-insensitivity will do the job for me (keeping the casing when Visual Studio rewrites the files), but I'd have to do this for every single file, which is rather annoying to do as the solution grows in file count. (and a pain in the bottom if I dare forget a file name)

How would I do this automatically through the project's build events?

有帮助吗?

解决方案

Running build events is not a good way to go. You're way better off having a dedicated build script to do the work for you.

Since you're on windows, checkout the use of PowerShell to run your builds... there's lots of resources out there. (personally I use PSAKE - pronounced sa-kee, as in Japanese rice wine)

Now, on to the renaming. Here's a snippet of code you can use to rename all files in a directory to the lower case equivalent.

Rename-Files.ps1

$dir = "$HOME\Projects\MyProjectDir\FilesToRename"
dir $dir | Rename-Item -NewName {$_.Name.ToLower()}

then from the console

> .\Rename-Files.ps1

note: don't forget to elevate powershell permissions

许可以下: CC-BY-SA归因
不隶属于 StackOverflow
scroll top