Haha, I have always been a lazy. This time I shared a batch processing script with several versions.
First: automatically modify the version number and check in to obtain the latest version, compile, and deploy it on the server.
Change XXX to your own one.
R program is a console program that you write to modify the version number.
Modify version number
1 using System; 2 using System.Collections.Generic; 3 using System.IO; 4 using System.Linq; 5 using System.Text; 6 using System.Text.RegularExpressions; 7 using System.Threading.Tasks; 8 9 namespace ResetVersionNum10 {11 class Program12 {13 static void Main(string[] args)14 {15 if(args.Length >= 1)16 {17 var path = args[0];18 var version = "0.0.*";19 if (args.Length >= 2 && !String.IsNullOrEmpty(args[1]) && IsMatchRule(args[1]))20 {21 version = args[1];22 }23 24 var streamRead = new FileStream(path, FileMode.Open);25 var streamWrite = new FileStream("_temp.txt", FileMode.Create);26 var reader = new StreamReader(streamRead);27 var writer = new StreamWriter(streamWrite);28 29 while (!reader.EndOfStream)30 {31 var str = reader.ReadLine();32 if(String.IsNullOrEmpty(str)) continue;33 if (str.Contains("AssemblyFileVersion")) continue;34 if (!str.StartsWith("//") && str.Contains("AssemblyVersion"))35 {36 str = "[assembly: AssemblyVersion(\"" + version + "\")]";37 }38 39 writer.WriteLine(str);40 }41 42 reader.Close();43 streamRead.Close();44 45 reader.Dispose();46 streamRead.Dispose();47 48 writer.Close();49 streamWrite.Close();50 51 writer.Dispose();52 streamWrite.Dispose();53 54 File.Copy("_temp.txt", path, true);55 }56 }57 58 static Boolean IsMatchRule(String version)59 {60 var regex = new Regex(@"\d.\d.\d|/*.\d|/*");61 return regex.IsMatch(version);62 }63 }64 }
@ Echo offset/p version = enter the version: Set vspath = c: \ Program Files (x86) \ Microsoft Visual Studio 11.0 \ common7 \ ide \ set tfsuserid = xxxset tfsuserpwd = xxxset deplaypath = D: \ websiteset svrip = 10. xxxxset svruserid = xxxset svruserpwd = xxxxset svrdeplaypath = % svrip % \ xxxxxxx: Get the latest version from TFs "% vspath % \ tf.exe" Get/All/login: % tfsuserid %, % tfsuserpwd %: setlocal enabledelayedexpansionfor/F % I in ('dir/S/B "assemblyinfo. CS "') Do (R % I % version %): Compile and release RD % deplaypath % \ s \ QC: \ windows \ Microsoft. net \ framework \ v4.0.30319 \ msbuild.exe XXXX \ XXXX. csproj/T: resolvereferences; Compile/T: _ wppcopywebapplication/P: configuration = release/P: webprojectoutputdir = % deplaypath % del/f/Q % deplaypath % \ bin \*. PDB: Copy to Server Net use \ % svrip %/User: % svruserid % svruserpwd % xcopy % deplaypath % \*. * % svrdeplaypath % \/e/H/D/y/R/V/F/K: delete published data RD % deplaypath % \ s \ q
The second version is simplified. TFs is not synchronized. After compilation and replication, a RAR compressed package is created and used to copy data to the official environment without modifying the version number ....
1 @ echo off 2 set Path = % ProgramFiles % \ WinRAR 3 set Path = % ProgramFiles % (x86) \ WinRAR 4 5 set deplaypath = F: \ publish-release-Sso 6 7 set svrip = 10. XXXX 8 set svruserid = Wanda \ XXX 9 set svruserpwd = xxx10 11 set svrdeplaypath = % svrip % \ XXXX \ 12 13: compiling and releasing 14 RD % deplaypath % \ s \ q15 C: \ windows \ Microsoft. net \ framework64 \ v4.0.30319 \ msbuild.exe XXXX \ XXXXX. csproj/T: resolvereferences; Compile/T: _ wppcopywebapplication/P: configuration = release/P: webprojectoutputdir = % deplaypath % 16 del/f/Q % deplaypath % \ bin \*. pdb17 18 del/f/Q % deplaypath % \ Web. config19 del/f/Q % deplaypath % \ setting. xml20 del/f/Q % deplaypath % \*. exe21 del/f/Q % deplaypath % \*. rar22 23: Copy to server 24. net use \ % svrip %/User: % svruserid % svruserpwd % 25 xcopy % deplaypath % \*. * \ % svrdeplaypath %/e/H/D/y/R/V/F/K26 27 copy zip. CMD % deplaypath % \ zip. 28 29: Package rar30 WinRAR A-As-r-k-ed-EP1-y-agyyyymmdd-nn-xupfiles % deplaypath % \ publish-% deplaypath % \ 31 32 :: delete published data 33 rd % deplaypath % \ s \ q
The third version, the self-extract format version, is different from the previous version. It is packaged into a self-decompressed version. before decompression, the official environment directory will be packaged and backed up.
1 @ echo off 2 3 set deplaypath = F: \ publish-release-Sso 4 5 set svrip = 10.xxx 6 set svruserid = Wanda \ XXXX 7 set svruserpwd = xxx 8 9 set svrdeplaypath = % svrip % \ XXXX \ 10 11 :: compile and Release 12 RD % deplaypath % \ s \ q13 C: \ WINDOWS \ Microsoft. net \ framework64 \ v4.0.30319 \ msbuild.exe XXXX \ XXXX. csproj/T: resolvereferences; Compile/T: _ wppcopywebapplication/P: configuration = release/P: webprojectoutputdir = % deplaypath % 14 del/f/Q % deplaypath % \ bin \*. pdb15 16 del/f/Q % deplaypath % \ Web. config17 del/f/Q % deplaypath % \ setting. xml18 del/f/Q % deplaypath % \*. exe19 20: copied to server 21. net use \ % svrip %/User: % svruserid % svruserpwd % 22 xcopy % deplaypath % \*. * \ % svrdeplaypath %/e/H/D/y/R/V/F/k23 24 copy zip. CMD % deplaypath % \ zip. limit 25 copy sfxpara.txt % deplaypath % \ sfxpara.txt 26 27: Package exe28 set Path = E: \ Program Files \ winrar29 WinRAR A-As-r-k-ed-EP1-y-agyyyymmdd-nn-SFX -zsfxpara.txt-xupfiles % deplaypath % \ publish-% deplaypath % \ 30 31:: delete published data 32 RD % deplaypath % \ s \ q
Silent = 1; Setup = decompress the file name and execute presetup = zip. cmdsetupcode.
The top side is the content of sfxpara.txt. I don't know why ..
Zip. CMD file content
1: Back up the previous version 2 set Path = % ProgramFiles % \ winrar3 set Path = % ProgramFiles % (x86) \ winrar4 mkdir xxx5 WinRAR A-As-r-k-ed-EP1-agyyyymmdd-nn-x *. WMV-x *. zip-x *. exe-x *. rar-xzip. CMD-xupfiles XXX \ XXX-Bak -*. * 6 move XXX .. \ Bak \