Every time I switch branches in Git I've got to update one line in one XML file so I can see my images (pulled from an image server) locally. I don't want a permanent solution to change the file (such as gitignore) because that file will change from time to time.
I want to run a batch that will simply alter this one line:
<add key="Images.RootUrl" value="//images.dev.foo.com:7000/" />
to
<add key="Images.RootUrl" value="//imagesperf.foo.com/" />
I'm trying to implement one of two methods I've found here on SO, but so far they elude me, partly because of all the quotes.
- creates new file but does not change line:
cd c:\Projects\Git\foo\Foo.Web.Store
FINDSTR /I /V /B "Images.RootUrl" Web.config > config.new
ECHO <add key="Images.RootUrl" value="//imagesperf.foo.com/" /> >> config.new
REM DEL Web.config
REM REN Web.new Web.config
PAUSE
- pretty sure I lost the plot about halfway through:
cd c:\Projects\Git\foo\Foo.Web.Store
for %%f in (Web.config) do (
for /f "tokens=1* delims=:" %%g in ('type "%%f" ^| findstr /n /v "images.dev.foo.com:7000"') do (
if "%%hx"=="x" (
echo.>>"tempWeb.config"
) else (
for /f "tokens=1* delims==" %%i in ('echo.%%h') do (
if "%%i"=="images.dev.foo.com:7000" (
echo.%%i=%%jimagesperf.foo.com>>"tempWeb.config"
) else (
if "%%jx"=="x" (
echo.%%i>>"tempWeb.config"
) else (
echo.%%i=%%j>>"tempWeb.config"
)
)
)
)
)
)
REM ren Web.config oldWeb.config
REM ren tempWeb.config Web.config