问题
I am an intern with a start-up company. I don't know anything about Batch files, XML files, the command prompt, or msbuild. I only know the basics of C#.
I have been asked to make a batch file that allows a user to build ALL solutions in a directory, with seven subfolders, in one command. I know how to build one solution in a single folder (by using msbuild mysolution.sln), but to build many solutions from seven different folders is beyond me.
It is possible to make a batch file that allows msbuild to find all solution files in the subfolders and build them all at once?
Thanks in advance for anyone who can help.
回答1:
Save following targets file as
buildall.targetsin the root of your solutions directory<Project ToolsVersion="4.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003" DefaultTargets="Default"> <ItemGroup> <AllFiles Include=".\**\*.sln"/> </ItemGroup> <Target Name="Default"> <MSBuild Projects="@(AllFiles)"/> </Target> </Project>Create batch file named
BuildAll.cmdwith following content: (change path to msbuild.exe depends on .NET Framework version you are using)C:\Windows\Microsoft.NET\Framework64\v4.0.30319\msbuild buildall.targetsRun/execute
BuildAll.cmd
See MSDN: How to: Select the Files to Build for more details on recursive folder traversal, especially "Specifying Inputs with Wildcards" part
来源:https://stackoverflow.com/questions/9608927/how-can-i-use-a-batch-file-to-msbuild-solutions-in-multiple-directories-at-once