Settings.targets 15.3 KB
Newer Older
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26
<Project DefaultTargets="Build" InitialTargets="RestoreToolsetCheck" xmlns="http://schemas.microsoft.com/developer/msbuild/2003" TreatAsLocalProperty="OutDir;Configuration">

  <PropertyGroup>
    <ProjectDir>$(MSBuildThisFileDirectory)..\..\</ProjectDir>
    <NuGetToolPath Condition="">$(ProjectDir)nuget.exe</NuGetToolPath>
    <ToolsetPackagesDir>$(ProjectDir)build\ToolsetPackages\</ToolsetPackagesDir>
    <ToolsetPackagesSemaphore>$(ToolsetPackagesDir)toolsetpackages.semaphore</ToolsetPackagesSemaphore>
    <NuGetPackageRoot Condition="'$(NuGetPackageRoot)' == ''">$(NUGET_PACKAGES)</NuGetPackageRoot> <!-- Respect environment variable if set -->
    <NuGetPackageRoot Condition="'$(NuGetPackageRoot)' == '' and
                                 '$(OS)' == 'Windows_NT'">$(UserProfile)\.nuget\packages</NuGetPackageRoot>
    <NuGetPackageRoot Condition="'$(NuGetPackageRoot)' == '' and
                                 '$(OS)' != 'Windows_NT'">$([System.Environment]::GetFolderPath(SpecialFolder.Personal))\.nuget\packages</NuGetPackageRoot>

    <!-- 
        $(OS) is only specific enough for windows builds.  For non-windows builds the identifier
        is specified on the command line of MSBuild
    -->
    <BaseNuGetRuntimeIdentifier Condition="'$(OS)' == 'Windows_NT'">win7</BaseNuGetRuntimeIdentifier>

    <!-- Turn on hard-linking on Windows to reduce copy time and disk space -->
    <CreateHardLinksForCopyLocalIfPossible Condition="'$(OS)' == 'Windows_NT'">true</CreateHardLinksForCopyLocalIfPossible>
  </PropertyGroup>

  <!-- Import the global NuGet packages -->
  <PropertyGroup>
    <ToolsetCompilerPackageName>Microsoft.Net.Compilers</ToolsetCompilerPackageName>
27
    <ToolsetCompilerPropsFilePath>$(NuGetPackageRoot)\Microsoft.Net.Compilers\1.2.0-beta1-20160202-02\build\Microsoft.Net.Compilers.props</ToolsetCompilerPropsFilePath>
28 29 30 31
    <RoslynDiagnosticsPropsFilePath>$(NuGetPackageRoot)\Microsoft.Net.RoslynDiagnostics\1.1.1-beta1-20150818-01\build\Microsoft.Net.RoslynDiagnostics.props</RoslynDiagnosticsPropsFilePath>
    <AdditionalFileItemNames>$(AdditionalFileItemNames);PublicAPI</AdditionalFileItemNames>
  </PropertyGroup>

32 33 34
  <UsingTask TaskName="Roslyn.MSBuild.Util.WriteCodeFragmentEx"
             AssemblyFile="C:\Users\jaredpar\code\roslyn\src\Tools\BuildUtil\BuildUtil\bin\Debug\Roslyn.MSBuild.Util.dll" />

35 36
  <Target Name="RestoreToolsetCheck"
      Condition="'$(BuildingProject)' == 'true'">
L
Llewellyn Pritchard 已提交
37
      <Error Text="Toolset packages have not been restored, run Restore.cmd before building"
38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53
             Condition="!Exists('$(ToolsetCompilerPropsFilePath)')" />
  </Target>

  <!-- Prevent vsix manifests from being copied to the shared output directory, makes build more deterministic -->
  <PropertyGroup>
    <CopyVsixManifestToOutput>false</CopyVsixManifestToOutput>
  </PropertyGroup>

  <!-- This file is imported by all projects at the beginning of the project files -->
  <Import Project="$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props"
          Condition="Exists('$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props') AND '$(MSBuildProjectExtension)' != '.vcxproj'" />

  <!-- NuGet props aren't imported by default on *nix so we do that here -->
  <Import Project="$(MSBuildExtensionsPath)\Microsoft\NuGet\Microsoft.NuGet.props"
          Condition="'$(OS)' != 'Windows_NT'" />

A
Andy Gocke 已提交
54 55 56 57 58
  <!-- The /publicsign argument is required for the compiler, but the current MSBuild
       build task can't be redirected and even if it could the new build task is not
       built against the xplat MSBuild references so it can't be loaded properly. Providing
       a response file works around the problem by directly adding the public sign argument
       to all unix compilations. This shouldn't present a problem as it's impossible to
A
Andy Gocke 已提交
59
       fully sign on unix at the moment anyway. Tracked by #7756. -->
A
Andy Gocke 已提交
60 61 62 63
  <PropertyGroup Condition="'$(OS)' != 'Windows_NT'">
      <CompilerResponseFile>$(MSBuildThisFileDirectory)..\scripts\extra_unix_args.rsp</CompilerResponseFile>
  </PropertyGroup>

64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146
  <PropertyGroup>
    <VisualStudioVersion Condition="'$(VisualStudioVersion)' == ''">14.0</VisualStudioVersion>
  </PropertyGroup>

  <PropertyGroup Condition="'$(DevEnvDir)' == ''">
    <DevEnvDir>$(VSINSTALLDIR)\Common7\IDE</DevEnvDir>
    <DevEnvDir Condition="'$(VisualStudioVersion)' == '12.0'">$(VS120COMNTOOLS)\..\IDE</DevEnvDir>
    <DevEnvDir Condition="'$(VisualStudioVersion)' == '14.0'">$(VS140COMNTOOLS)\..\IDE</DevEnvDir>
    <DevEnvDir>$([System.IO.Path]::GetFullPath('$(DevEnvDir)'))</DevEnvDir>
  </PropertyGroup>

  <PropertyGroup>
    <VisualStudioReferenceMajorVersion Condition="'$(VisualStudioReferenceMajorVersion)' == ''">$(VisualStudioVersion.Substring(0, $(VisualStudioVersion.IndexOf('.'))))</VisualStudioReferenceMajorVersion>
    <VisualStudioReferenceAssemblyVersion Condition="'$(VisualStudioReferenceAssemblyVersion)' == ''">$(VisualStudioReferenceMajorVersion).0.0.0</VisualStudioReferenceAssemblyVersion>
    <VisualStudioCodename>Dev$(VisualStudioReferenceMajorVersion)</VisualStudioCodename>

    <VSToolsPath Condition="'$(VSToolsPath)' == ''">$(MSBuildExtensionsPath32)\Microsoft\VisualStudio\v$(VisualStudioVersion)</VSToolsPath>
    <MinimumVisualStudioVersion>$(VisualStudioVersion)</MinimumVisualStudioVersion>

    <VSLToolsPath Condition="'$(VSLToolsPath)' == ''">$([System.IO.Path]::GetFullPath('$(MSBuildThisFileDirectory)\..'))</VSLToolsPath>
    <VSLTargetsPath Condition="'$(VSLTargetsPath)' == ''">$(MSBuildThisFileDirectory)</VSLTargetsPath>

    <Configuration Condition="'$(Configuration)' == ''">Debug</Configuration>

    <SignAssembly Condition="'$(SignAssembly)' == ''">true</SignAssembly>

    <UseRoslynAnalyzers Condition="'$(UseRoslynAnalyzers)' == ''">true</UseRoslynAnalyzers>

    <!-- If we're on Visual Studio 2015 RTM and  we still have Roslyn installed, our VSIX-producing packages are not going to install, so let's not even try.
         Update 1 supports this, so we'll use csi.exe's existence as a simple proxy for whether we have Update 1 installed or not. -->
    <DeployExtension Condition="'$(DeployExtension)' == '' AND Exists('$(DevEnvDir)\CommonExtensions\Microsoft\Roslyn\Language Services\extension.vsixmanifest') AND !Exists('$(MSBuildBinPath)\csi.exe')">false</DeployExtension>
  </PropertyGroup>

  <Choose>
    <When Condition="'$(VisualStudioVersion)' == '12.0'">
      <PropertyGroup>
        <MSBuildAssemblyNameFragment>v12.0</MSBuildAssemblyNameFragment>
      </PropertyGroup>
    </When>

    <Otherwise>
      <PropertyGroup>
        <MSBuildAssemblyNameFragment>Core</MSBuildAssemblyNameFragment>
      </PropertyGroup>
    </Otherwise>
  </Choose>

  <!-- Build reliability -->
  <PropertyGroup>
    <OverwriteReadOnlyFiles Condition="'$(OverwriteReadOnlyFiles)' == ''">true</OverwriteReadOnlyFiles>
  </PropertyGroup>

  <!-- Don't validate our .vsixmanifests for correct schemas. Right now our build machines are on Visual Studio 2015 RTM, but we want to set a property
       (Experimental) that was added in Update 1. Since the schema is pulled from the box, you can't build with RTM unless we either disable schema
       validation or otherwise copy the schemas in and then point the target to those. Since schema changes happen fairly rarely, I'll just disable
       schema validation and turn it on as soon as we're on update 1 only. -->
  <PropertyGroup>
    <BypassVsixValidation>true</BypassVsixValidation>
  </PropertyGroup>

  <!-- Project language -->
  <PropertyGroup Condition="'$(ProjectLanguage)' == ''">
    <ProjectLanguage Condition="'$(MSBuildProjectExtension)' == '.csproj' OR '$(Language)' == 'C#'">CSharp</ProjectLanguage>
    <ProjectLanguage Condition="'$(MSBuildProjectExtension)' == '.vbproj' OR '$(Language)' == 'VB'">VB</ProjectLanguage>
    <ProjectLanguage Condition="'$(MSBuildProjectExtension)' == '.vcxproj' OR '$(Language)' == 'C++'">C++</ProjectLanguage>
  </PropertyGroup>

  <PropertyGroup Condition="'$(OS)' == 'Windows_NT'">
    <!-- Use the compiler server -->
    <UseSharedCompilation>true</UseSharedCompilation>
  </PropertyGroup>

  <!-- Import the props files from the toolset NuGet packages if we're not in a bootstrap build -->
  <ImportGroup Label="GlobalNuGets" Condition="'$(BootstrapBuildPath)' == ''">
    <Import Project="$(ToolsetCompilerPropsFilePath)"
            Condition="Exists('$(ToolsetCompilerPropsFilePath)')" />
  </ImportGroup>

  <ImportGroup>
    <Import Project="$(RoslynDiagnosticsPropsFilePath)"
            Condition="Exists('$(RoslynDiagnosticsPropsFilePath)') And ('$(UseRoslynAnalyzers)' == 'true')" />
  </ImportGroup>

A
Andy Gocke 已提交
147 148
  <!-- Otherwise, use the task from the bootstrap location. This is necessary
       to support new properties on the build task. -->
149 150 151 152 153 154 155
  <UsingTask TaskName="Microsoft.CodeAnalysis.BuildTasks.Csc"
             AssemblyFile="$(BootstrapBuildPath)\Microsoft.Build.Tasks.CodeAnalysis.dll"
             Condition="'$(BootstrapBuildPath)' != ''" />
  <UsingTask TaskName="Microsoft.CodeAnalysis.BuildTasks.Vbc"
             AssemblyFile="$(BootstrapBuildPath)\Microsoft.Build.Tasks.CodeAnalysis.dll"
             Condition="'$(BootstrapBuildPath)' != ''" />

156
  <PropertyGroup Condition="'$(BootstrapBuildPath)' != ''">
157 158 159
    <UseSharedCompilation>true</UseSharedCompilation>
    <CSharpCoreTargetsPath>$(BootstrapBuildPath)\Microsoft.CSharp.Core.targets</CSharpCoreTargetsPath>
    <VisualBasicCoreTargetsPath>$(BootstrapBuildPath)\Microsoft.VisualBasic.Core.targets</VisualBasicCoreTargetsPath>
160 161
  </PropertyGroup>

162

163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296
  <!-- Common project settings -->
  <PropertyGroup>
    <DeployToSamplesSubfolder Condition="'$(DeployToSamplesSubfolder)' == ''">false</DeployToSamplesSubfolder>
    <FileAlignment>512</FileAlignment>
    <HighEntropyVA>true</HighEntropyVA>
  </PropertyGroup>

  <!--
    If TargetNetFX20 is true the project targets Framework 2.0 reference assemblies provided by Microsoft.NetFX20 nuget package.
    Use the latest Framework toolset to build, but set msbuild properties below
    so to avoid 4.5 specific artifacts to be added to the compilation (references, attributes).
  -->
  <PropertyGroup Condition="'$(TargetNetFX20)' == 'true'">
    <GenerateTargetFrameworkAttribute>false</GenerateTargetFrameworkAttribute>
    <AddAdditionalExplicitAssemblyReferences>false</AddAdditionalExplicitAssemblyReferences>
    <NoStdLib>true</NoStdLib>
    <FrameworkPathOverride>$(NuGetPackageRoot)\Microsoft.NetFX20\1.0.3\lib\net20</FrameworkPathOverride>
    <NuGetTargetMoniker>.NETFramework,Version=v2.0</NuGetTargetMoniker>
  </PropertyGroup>

  <ItemGroup Condition="'$(ProjectLanguage)' == 'CSharp' AND '$(TargetNetFX20)' == 'true'">
    <_ExplicitReference Include="$(FrameworkPathOverride)\mscorlib.dll" />
  </ItemGroup>

  <PropertyGroup>
    <OutDir Condition="'$(OutDir)' == ''">$([System.IO.Path]::GetFullPath('$(MSBuildThisFileDirectory)\..\..\Binaries\$(Configuration)'))\</OutDir>
    <BaseIntermediateOutputPath Condition="'$(BaseIntermediateOutputPath)' == ''">$([System.IO.Path]::GetFullPath('$(MSBuildThisFileDirectory)\..\..\Binaries\Obj\$(MSBuildProjectName)'))\</BaseIntermediateOutputPath>
  </PropertyGroup>

  <PropertyGroup>
    <!-- Capture the root, so we'll always have it even if we're building to a sub-folder -->
    <VSLOutDir>$(OutDir)</VSLOutDir>
  </PropertyGroup>

  <PropertyGroup Condition="'$(DeployToSamplesSubfolder)' == 'true'">
    <OutDir>$(OutDir)\Samples\$(MSBuildProjectName)</OutDir>
  </PropertyGroup>

  <PropertyGroup>
  <!-- Disable AppX packaging for the Roslyn source. Not setting this to false has the side effect
       that any builds of portable projects end up in a sub folder of $(OutDir). Search for this flag in
       Microsoft.Common.CurrentVersion.targets to see how it is consumed -->
    <WindowsAppContainer>false</WindowsAppContainer>
  </PropertyGroup>

  <Choose>
    <!-- VB specific settings -->
    <When Condition="'$(ProjectLanguage)' == 'VB'">
      <PropertyGroup>
        <MyType>Empty</MyType>
        <OptionCompare>Binary</OptionCompare>
        <OptionExplicit>On</OptionExplicit>
        <OptionInfer>On</OptionInfer>
        <OptionStrict>On</OptionStrict>
        <RootNamespace></RootNamespace>
        <VBRuntime>Embed</VBRuntime>
      </PropertyGroup>
      <ItemGroup>
        <Import Include="Microsoft.VisualBasic" />
        <Import Include="System" />
        <Import Include="System.Collections" />
        <Import Include="System.Collections.Generic" />
        <Import Include="System.Diagnostics" />
      </ItemGroup>
      <ItemGroup Condition="'$(TargetNetFX20)' != 'true'">
        <Import Include="System.Linq" />
      </ItemGroup>
      <PropertyGroup Condition="'$(Configuration)' == 'Debug'">
        <DebugSymbols>true</DebugSymbols>
        <DefineDebug>true</DefineDebug>
        <DefineTrace>true</DefineTrace>
        <DebugType>full</DebugType>
      </PropertyGroup>
      <PropertyGroup Condition="'$(Configuration)' == 'Release'">
        <DefineTrace>true</DefineTrace>
        <Optimize>true</Optimize>
        <DebugType>pdbonly</DebugType>
      </PropertyGroup>
    </When>

    <!-- C# specific settings -->
    <When Condition="'$(ProjectLanguage)' == 'CSharp'">
      <PropertyGroup>
        <WarningLevel>4</WarningLevel>
        <ErrorReport>prompt</ErrorReport>

        <!-- Suppress the following warnings by default for C# projects
                1591: So far we've chosen to implicitly implement interfaces and as a consequence
                      the methods are public.  We don't want to duplicate documentation for them
                      and hence suppress this warning until we get closer to release and a more
                      thorough documentation story

        -->
        <NoWarn>1591</NoWarn>
      </PropertyGroup>
      <PropertyGroup Condition="'$(Configuration)' == 'Debug'">
        <DebugSymbols>true</DebugSymbols>
        <DebugType>full</DebugType>
        <DefineConstants>DEBUG;TRACE</DefineConstants>
      </PropertyGroup>
      <PropertyGroup Condition="'$(Configuration)' == 'Release'">
        <DebugType>pdbonly</DebugType>
        <DefineConstants>TRACE</DefineConstants>
        <Optimize>true</Optimize>
      </PropertyGroup>
    </When>

    <!-- C++ specific settings -->
    <When Condition="'$(ProjectLanguage)' == 'C++'">
      <PropertyGroup>
        <!-- Put intermediate outputs in the same place as managed projects for sanity -->
        <IntDir>$(ProjectDir)obj\$(Configuration)\</IntDir>

        <!-- We just always want to build with whatever toolset matches the VS you're building with -->
        <PlatformToolset>v$(VisualStudioReferenceMajorVersion)0</PlatformToolset>
      </PropertyGroup>
    </When>
  </Choose>

  <PropertyGroup>
    <!-- SN is in the Framework SDK tools path, but TargetFrameworkSDKToolsDirectory isn't always available  -->
    <SnToolPath Condition=" '$(TargetFrameworkSDKToolsDirectory)' != '' ">$(TargetFrameworkSDKToolsDirectory)\sn.exe</SnToolPath>
    <SnToolPath Condition=" '$(TargetFrameworkSDKToolsDirectory)' == '' ">$(MSBuildProgramFiles32)\Microsoft SDKs\Windows\v8.0A\bin\NETFX 4.0 Tools\sn.exe</SnToolPath>

    <EditBinToolPath>$(MSBuildProgramFiles32)\Microsoft Visual Studio $(VisualStudioVersion)\VC\bin\editbin.exe</EditBinToolPath>

  </PropertyGroup>

  <PropertyGroup>
    <CopyVSReferencesToOutput>True</CopyVSReferencesToOutput>
    <AuthenticodeCertificateName>MicrosoftSHA1</AuthenticodeCertificateName>
    <FakeSignToolPath>$(NuGetPackageRoot)\FakeSign\0.9.2\tools\FakeSign.exe</FakeSignToolPath>
  </PropertyGroup>
 </Project>