replace - bat file to modify web.config setting -
i have web application created in visual studio 2013. have appsetting in web.config file:
<add key="cloudversion" value="@@new@@"/>
after publish application, run bat file copies published directory, appends today's date directory name, compresses updated directory, , uploads google drive rest of team can access it.
i attempting use same bat file modify cloudversion setting can see when published within application. have code:
@echo off &setlocal set "search=@@new@@" set "replace=%yy%%mm%%dd%" (for /f "delims=" %%i in ('findstr /n "^" "%""c:\original files\web.config""%"') ( set "line=%%i" setlocal enabledelayedexpansion set "line=!line:%search%=%replace%!" echo(!line! endlocal ))>"%""c:\publish folder\cloud"%yy%.%mm%.%dd%"\web.config""%" type "%""c:\publish folder\cloud"%yy%.%mm%.%dd%"\web.config""%"
it correctly copies web.config file , replaces cloudversion variable value. however, whole file has each line numbered this:
23: </system.web.extensions> 24: <appsettings> 25: <add key="cloudversion" value="20140818"/>
how use bat update value, not numbered lines have later delete?
in case looking, here did:
@echo off &setlocal set "search=@@new@@" set "replace=%yy%%mm%%dd%" (for /f "delims=" %%i in ('findstr "^" "%""c:\original files\web.config""%"') ( set "line=%%i" setlocal enabledelayedexpansion set "line=!line:%search%=%replace%!" echo(!line! endlocal ))>"%""c:\publish folder\cloud"%yy%.%mm%.%dd%"\web.config""%" type "%""c:\publish folder\cloud"%yy%.%mm%.%dd%"\web.config""%"
Comments
Post a Comment