I want to get web.config transformations working locally but apparently the transformations only occur when doing deployments.
Does anybody know of a way to run the msbuild target "TransformWebConfig" without it going through the "rebuild" process and also specify and output directory where to spit out the transformed web.config?
-Diego
~~~~~~~~~~~~~~~~~
EDIT
~~~~~~~~~~~~~~~~~
Using Sayed's answer, I created a .bat file to do run the task for me:
C:\Windows\Microsoft.NET\Framework64\v4.0.30319\Msbuild.exe "D:\Demo\Transformation.proj" /t:TransformWebConfig
copy /Y "D:\Demo\Web.config" "D:\MyProject\Web.config"
del ""D:\Demo\Web.config"
the "Transformation.proj" is a copy of Sayed's code snippet in the answer below. Just specify the source, target, and destination for the transformation. The new file, in this case, the transformed "web.config" will be in the "D:\Demo" directory. I am simply copying it over to overwrite my project's web.config and, finally, deleting the generated file in the "demo" folder.
Also, I created a macro to run this batch file and perform the tranformation for me:
Public Module DoTransform
Sub RunTransformBatchFile()
Try
Process.Start("D:\Demo\RunTransform.bat")
Catch ex As System.Exception
MsgBox(ex.Message)
End Try
End Sub
End Module
You can also add a button on your toolbar to run this batch and/or assign a shortcut key to execute.
Thanks a lot Sayed!
-Diego