Get build working in any command window

- Prefer VS 2013 (v12.0) version of MSBuild.exe and fallback to v4.0 when necessary
- Do not rely on %Path% since that limits us to VS developer cmd windows
- Match Microsoft.Build.Tasks*.dll version to MSBuild.exe, not type of cmd window
- Have tested building in VS 2013, VS 2013 dev cmd window, and bare cmd window

Requires either a FxCopCmd.exe.config binding redirect or David's "VS2013 FxCop
compatibility" change for full VS 2013 support.
This commit is contained in:
dougbu 2013-11-08 16:05:08 -08:00
Родитель c9c33e387d
Коммит 1bfee49f63
2 изменённых файлов: 10 добавлений и 4 удалений

Просмотреть файл

@ -1,18 +1,23 @@
@echo off
pushd %~dp0
setlocal
if exist bin goto build
mkdir bin
:Build
set MSBuild="%ProgramFiles(x86)%\MSBuild\12.0\Bin\MsBuild.exe"
if not exist %MSBuild% @set MSBuild="%ProgramFiles%\MSBuild\12.0\Bin\MsBuild.exe"
if not exist %MSBuild% @set MSBuild="%SystemRoot%\Microsoft.NET\Framework\v4.0.30319\MSBuild.exe"
if "%1" == "" goto BuildDefaults
%SystemRoot%\Microsoft.NET\Framework\v4.0.30319\msbuild Runtime.msbuild /m /nr:false /t:%* /p:Platform="Any CPU" /p:Desktop=true /v:M /fl /flp:LogFile=bin\msbuild.log;Verbosity=Normal
%MSBuild% Runtime.msbuild /m /nr:false /t:%* /p:Platform="Any CPU" /p:Desktop=true /v:M /fl /flp:LogFile=bin\msbuild.log;Verbosity=Normal
if %ERRORLEVEL% neq 0 goto BuildFail
goto BuildSuccess
:BuildDefaults
%SystemRoot%\Microsoft.NET\Framework\v4.0.30319\msbuild Runtime.msbuild /m /nr:false /p:Platform="Any CPU" /p:Desktop=true /v:M /fl /flp:LogFile=bin\msbuild.log;Verbosity=Normal
%MSBuild% Runtime.msbuild /m /nr:false /p:Platform="Any CPU" /p:Desktop=true /v:M /fl /flp:LogFile=bin\msbuild.log;Verbosity=Normal
if %ERRORLEVEL% neq 0 goto BuildFail
goto BuildSuccess
@ -28,3 +33,4 @@ goto end
:End
popd
endlocal

Просмотреть файл

@ -1,9 +1,9 @@
<Project ToolsVersion="4.0" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<Import Project="..\..\tools\WebStack.tasks.targets"/>
<PropertyGroup>
<CodeTaskFactoryAssemblyFile Condition=" '$(CodeTaskFactoryAssemblyFile)' == '' And '$(BuildingInsideVisualStudio)' == 'true' And '$(VisualStudioVersion)' == '12.0' ">$(MSBuildToolsPath)\Microsoft.Build.Tasks.v12.0.dll</CodeTaskFactoryAssemblyFile>
<CodeTaskFactoryAssemblyFile Condition=" '$(CodeTaskFactoryAssemblyFile)' == '' And '$(MSBuildToolsVersion)' == '12.0' ">$(MSBuildToolsPath)\Microsoft.Build.Tasks.v12.0.dll</CodeTaskFactoryAssemblyFile>
<CodeTaskFactoryAssemblyFile Condition=" '$(CodeTaskFactoryAssemblyFile)' == '' ">$(MSBuildToolsPath)\Microsoft.Build.Tasks.v4.0.dll</CodeTaskFactoryAssemblyFile>
<BuildTaskAssemblyReference Condition=" '$(BuildTaskAssemblyReference)' == '' And '$(BuildingInsideVisualStudio)' == 'true' And '$(VisualStudioVersion)' == '12.0' ">Microsoft.Build.Tasks.v12.0</BuildTaskAssemblyReference>
<BuildTaskAssemblyReference Condition=" '$(BuildTaskAssemblyReference)' == '' And '$(MSBuildToolsVersion)' == '12.0' ">Microsoft.Build.Tasks.v12.0</BuildTaskAssemblyReference>
<BuildTaskAssemblyReference Condition=" '$(BuildTaskAssemblyReference)' == '' ">Microsoft.Build.Tasks.v4.0</BuildTaskAssemblyReference>
</PropertyGroup>
<UsingTask TaskName="NuGetPack" TaskFactory="CodeTaskFactory" AssemblyFile="$(CodeTaskFactoryAssemblyFile)">