Settings.targets 15.3 KB
Newer Older
1 2 3 4 5 6 7 8 9 10 11
<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
A
Andy Gocke 已提交
12
                                 '$(OS)' != 'Windows_NT'">$(HOME)\.nuget\packages</NuGetPackageRoot>
13 14 15 16 17 18 19 20 21 22 23

    <!-- 
        $(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>
  </PropertyGroup>

  <!-- Import the global NuGet packages -->
  <PropertyGroup>
    <ToolsetCompilerPackageName>Microsoft.Net.Compilers</ToolsetCompilerPackageName>
J
Jared Parsons 已提交
24
    <ToolsetCompilerPropsFilePath>$(NuGetPackageRoot)\Microsoft.Net.Compilers\1.2.0-rc\build\Microsoft.Net.Compilers.props</ToolsetCompilerPropsFilePath>
25
    <RoslynDiagnosticsPropsFilePath>$(NuGetPackageRoot)\Microsoft.Net.RoslynDiagnostics\1.1.1-beta1-20150818-01\build\Microsoft.Net.RoslynDiagnostics.props</RoslynDiagnosticsPropsFilePath>
26
    <RoslynBuildUtilFilePath>$(NuGetPackageRoot)\Roslyn.Build.Util\0.9.4-portable\lib\dotnet\Roslyn.MSBuild.Util.dll</RoslynBuildUtilFilePath>
27 28 29
    <AdditionalFileItemNames>$(AdditionalFileItemNames);PublicAPI</AdditionalFileItemNames>
  </PropertyGroup>

30 31 32 33 34
  <!-- 
    Roslyn uses the WriteCodeFragment task to output generated assembly attributes.  In MSBuild 14.0 update 1 this task 
    produces non-deterministic output.  This is fixed in update 2 but until that is released we use a hand patched
    version of the Task that is deterministic.  

J
Cleanup  
Jared Parsons 已提交
35 36
    MSBuild bug: https://github.com/Microsoft/msbuild/issues/408
    Bug tracking removing this: https://github.com/dotnet/roslyn/issues/8421
37
  -->
38
  <UsingTask TaskName="Roslyn.MSBuild.Util.WriteCodeFragmentEx"
A
Andy Gocke 已提交
39
             AssemblyFile="$(RoslynBuildUtilFilePath)" />
40

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

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

52 53 54 55 56
  <!-- Point to the reference assemblies on unix -->
  <PropertyGroup Condition="'$(OS)' != 'Windows_NT'">
      <TargetFrameworkRootPath>$(MSBuildBinPath)\reference-assemblies\Framework</TargetFrameworkRootPath>
  </PropertyGroup>

57 58 59 60 61 62 63 64
  <!-- 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 已提交
65 66 67 68 69
  <!-- 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 已提交
70
       fully sign on unix at the moment anyway. Tracked by #7756. -->
A
Andy Gocke 已提交
71
  <PropertyGroup Condition="'$(OS)' != 'Windows_NT'">
72
      <CompilerResponseFile>$(MSBuildThisFileDirectory)..\unix\extra_unix_args.rsp</CompilerResponseFile>
A
Andy Gocke 已提交
73 74
  </PropertyGroup>

75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94
  <PropertyGroup>
    <VisualStudioVersion Condition="'$(VisualStudioVersion)' == ''">14.0</VisualStudioVersion>
  </PropertyGroup>

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

    <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>

95
    <Deterministic>True</Deterministic>
96 97 98 99

    <!-- Only portable PDBs are supported xplat -->
    <DebugType Condition="'$(OS)' != 'Windows_NT'">portable</DebugType>
    <DebugType Condition="'$(OS)' == 'Windows_NT'">pdbonly</DebugType>
100 101
  </PropertyGroup>

T
Tanner Gooding 已提交
102 103 104 105 106 107 108 109 110
  <PropertyGroup Condition="'$(VSCOMNTOOLS)' == ''">
    <VSCOMNTOOLS>$([System.Environment]::ExpandEnvironmentVariables("%VS$(VisualStudioReferenceMajorVersion)0COMNTOOLS%"))</VSCOMNTOOLS>
  </PropertyGroup>
  
  <PropertyGroup Condition="'$(DevEnvDir)' == ''">
    <DevEnvDir>$(VSCOMNTOOLS)\..\IDE</DevEnvDir>
    <DevEnvDir>$([System.IO.Path]::GetFullPath('$(DevEnvDir)'))</DevEnvDir>
  </PropertyGroup>
  
111 112 113 114 115 116 117 118 119 120 121 122 123 124
  <Choose>
    <When Condition="'$(VisualStudioVersion)' == '12.0'">
      <PropertyGroup>
        <MSBuildAssemblyNameFragment>v12.0</MSBuildAssemblyNameFragment>
      </PropertyGroup>
    </When>

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

125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140
  <Choose>
    <When Condition="'$(VisualStudioVersion)' == '15.0'">
      <PropertyGroup>
        <VisualStudioBuildToolsNuGetPackagePath>$(NuGetPackageRoot)\Microsoft.VSSDK.BuildTools\15.0.25201-dev15preview2</VisualStudioBuildToolsNuGetPackagePath>
      </PropertyGroup>
    </When>

    <Otherwise>
      <PropertyGroup>
        <VisualStudioBuildToolsNuGetPackagePath>$(NuGetPackageRoot)\Microsoft.VSSDK.BuildTools\14.2.25201</VisualStudioBuildToolsNuGetPackagePath>
      </PropertyGroup>
    </Otherwise>
  </Choose>

  <Import Project="$(VisualStudioBuildToolsNuGetPackagePath)\build\Microsoft.VsSDK.BuildTools.props" Condition="'$(OS)' == 'Windows_NT'" />

141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160
  <!-- Build reliability -->
  <PropertyGroup>
    <OverwriteReadOnlyFiles Condition="'$(OverwriteReadOnlyFiles)' == ''">true</OverwriteReadOnlyFiles>
  </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)"
161
            Condition="Exists('$(ToolsetCompilerPropsFilePath)') And '$(OS)' == 'Windows_NT'" />
162 163 164 165 166 167 168
  </ImportGroup>

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

A
Andy Gocke 已提交
169 170
  <!-- Otherwise, use the task from the bootstrap location. This is necessary
       to support new properties on the build task. -->
171 172 173 174 175 176 177
  <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)' != ''" />

178
  <PropertyGroup Condition="'$(BootstrapBuildPath)' != ''">
179 180 181
    <UseSharedCompilation>true</UseSharedCompilation>
    <CSharpCoreTargetsPath>$(BootstrapBuildPath)\Microsoft.CSharp.Core.targets</CSharpCoreTargetsPath>
    <VisualBasicCoreTargetsPath>$(BootstrapBuildPath)\Microsoft.VisualBasic.Core.targets</VisualBasicCoreTargetsPath>
182 183
  </PropertyGroup>

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
  <!-- 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>

219 220 221 222
  <PropertyGroup>
      <CompilerGeneratorToolsDir>$(OutDir)CompilerGeneratorTools\</CompilerGeneratorToolsDir>
  </PropertyGroup>

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 297 298 299 300 301 302 303 304 305
  <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>
      </PropertyGroup>
      <PropertyGroup Condition="'$(Configuration)' == 'Release'">
        <DefineTrace>true</DefineTrace>
        <Optimize>true</Optimize>
      </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>
        <DefineConstants>DEBUG;TRACE</DefineConstants>
      </PropertyGroup>
      <PropertyGroup Condition="'$(Configuration)' == 'Release'">
        <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>
    <CopyVSReferencesToOutput>True</CopyVSReferencesToOutput>
C
CyrusNajmabadi 已提交
306
    <AuthenticodeCertificateName>Microsoft402</AuthenticodeCertificateName>
307
  </PropertyGroup>
J
Jared Parsons 已提交
308 309 310 311 312 313 314 315 316 317 318 319

  <!-- 
    When running our determinism tests we need to copy the diagnostic file from the intermediate directory 
    to the location of the binary.  This ensures .dll and .dll.key are next to each other to be picked up
    by our test scripts
  -->
  <Target Name="CopyDeterministicBuildDiagnosticFile" Condition="'$(DebugDeterminism)' != ''" AfterTargets="CoreCompile">
    <Copy
        Condition="Exists(@(IntermediateAssembly -> '%(fullpath).key'))"
        SourceFiles="@(IntermediateAssembly -> '%(fullpath).key')"
        DestinationFolder="$(OutDir)" />
  </Target>
320
 </Project>