' Ce script doit porté l'extension ".vbs" pour fontionner, je le dis quand-même ;) ' Ce script a pour objectif de compiler de projet Web "WebSite1" dans un répertoire local. ' Puis de transférer la nouvelle compilation vers un répertoire distant (serveur local ou VPN). ' La variable timestamp sert pour créer un sous dossier pour chaque nouvelle compilation. Dim timestamp timestamp = year(now) & month(now) & day(now) & "-" & hour(now) & minute(now) & second(now) ' La variable timestamp pointe directement sur le dossier sources du projet. Dim dossierSources dossierSources = "C:\MesProjetWeb\Sources\WebSite1" ' La variable dossierTempCompilation pointe dans un dossier temporaire qui accumule chaque nouvelle compilation. Dim dossierTempCompilation dossierTempCompilation= "C:\MesProjetWeb\Precompilations\WebSite1\" & timestamp ' La variable dossierProdServer pointe dans un dossier d'hébergement final sur votre serveur. Dim dossierProdServer dossierProdServer = "\\192.168.1.10\wwwroot\WebSite1" msgbox "Ce script va compiler le projet WebSite1 ("&dossierSources&")" & vbcrlf & "dans le répertoire (" & dossierTempCompilation & ")" & vbcrlf & "et copier le tout dans le répertoire (" & dossierProdServer &")" & vbcrlf & "en 3 étapes...",64,"Information" Set objFSO = CreateObject("scripting.FileSystemObject") Dim boolContinu boolContinu = True if boolContinu then if msgbox("Etape 1 - Précompilation du projet - ok ?",4,"Question") = 6 then '6 pour yes 'precompilation Dim WSHShell Set WSHShell = WScript.CreateObject("WScript.Shell") WSHShell.Run "C:\WINDOWS\Microsoft.NET\Framework\v2.0.50727\aspnet_compiler -v /Deployment -p "&dossierSources&" "&dossierTempCompilation&" -u", 3, true Set WSHShell = Nothing else boolContinu = False end if end if if boolContinu then if msgbox("Etape 2 - Suppression des fichiers & dossiers inutiles - ok ?",4,"Question") = 6 then '6 pour yes ' On se débrasse du fichier "web.config" de dev, celui sur la prod. étant différement paramétré... if objFSO.FileExists(dossierTempCompilation&"\web.config") then objFSO.DeleteFile dossierTempCompilation&"\web.config",true else msgbox dossierTempCompilation&"\web.config introuvable",48,"Information" end if ' Dans mon projet, je ne veux pas retransférer toutes mes images à chaque mise à jour... if objFSO.FolderExists(dossierTempCompilation&"\images") then objFSO.DeleteFolder dossierTempCompilation&"\images",true else msgbox dossierTempCompilation&"\images introuvable",48,"Information" end if else boolContinu = False end if end if ' C'est prêt, transfert vers le dossier d'hébergement sur le serveur if boolContinu then if msgbox("Etape 3 - Copie du résultat sur le serveur ok ?",4,"Question") = 6 then '6 pour yes if not objFSO.FolderExists(dossierProdServer) then objFSO.CreateFolder dossierProdServer end if objFSO.CopyFolder dossierTempCompilation , dossierProdServer, true else boolContinu = False end if end if Set objFSO = Nothing if boolContinu then msgbox "Vous quittez le script...",64,"Information" else msgbox "Vous abandonnez le script...",64,"Information" end if