1 <?xml version="1.0" encoding="utf-8"?>
2 <Project ToolsVersion="12.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003" InitialTargets="CheckDesignTime">
4 <!-- Provide default targets which can be hooked onto or overridden as necessary -->
5 <Target Name="BuildAndTest" DependsOnTargets="Build;Test" />
6 <Target Name="RebuildAndTest" DependsOnTargets="Rebuild;Test" />
10 <!-- Due to a bug in the Roslyn Microsoft.NETCore.Compilers.props file, VisualBasicCoreTargetsPath is not set, and instead they set BasicCoreTargetsPath so the wrong targets get imported -->
11 <VisualBasicCoreTargetsPath Condition="'$(VisualBasicCoreTargetsPath)' == '' And '$(BasicCoreTargetsPath)' != ''">$(BasicCoreTargetsPath)</VisualBasicCoreTargetsPath>
13 <BuildToolsTaskDir Condition="'$(BuildToolsTaskDir)' == ''">$(ToolsDir)</BuildToolsTaskDir>
15 <!-- For UAP, we need to bin place the resources as resw files to create the runner's pri file. -->
16 <ResourcesFolderPath Condition="'$(ResourcesFolderPath)' == ''">$(RuntimePath)resw</ResourcesFolderPath>
18 <!-- A number of the imports below depend on these default properties -->
19 <AssemblyVersion Condition="'$(AssemblyVersion)'==''">999.999.999.999</AssemblyVersion>
20 <CLSCompliant Condition="'$(CLSCompliant)'=='' and '$(IsTestProject)'=='true'">false</CLSCompliant>
21 <CLSCompliant Condition="'$(CLSCompliant)'==''">true</CLSCompliant>
24 Check if the project has been localized by looking for the existence of the .de.xlf file. By convention, we assume that if
25 a project is localized in German, then it is localized in all languages.
27 <ExcludeLocalizationImport Condition="'$(ExcludeLocalizationImport)'=='' And !Exists('$(MSBuildProjectDirectory)/MultilingualResources/$(MSBuildProjectName).de.xlf')">true</ExcludeLocalizationImport>
30 <!-- used by test projects that need to copy supplemental content to the output directory -->
31 <ItemDefinitionGroup Condition="'$(IsTestProject)'=='true'">
32 <SupplementalTestData>
34 </SupplementalTestData>
35 </ItemDefinitionGroup>
37 <!-- Assembly metadata indicating that an assembly is a framework (as opposed to user) assembly:
38 Test projects need to not have this because of the way "IsFrameworkAssembly" APIs work to check this. -->
39 <ItemGroup Condition="'$(IsDotNetFrameworkProductAssembly)' == 'true' AND '$(IsTestProject)' != 'true'" >
40 <AssemblyMetadata Include=".NETFrameworkAssembly">
43 <AssemblyMetadata Include="Serviceable">
46 <AssemblyMetadata Include="PreferInbox">
52 Import the provides support for EnsureBuildToolsRuntime target which will restore a .NET Core based
53 runtime and setup a $(ToolRuntimePath) and $(ToolHost) for others to consume.
55 This must be imported before any tools that need to use it are imported.
57 <Import Project="$(MSBuildThisFileDirectory)toolruntime.targets" Condition="'$(ExcludeToolRuntimeImport)' != 'true'"/>
60 Import the reference assembly targets
62 This must be imported early because it modifies OutputPath and IntermediateOutputPath
65 Depends on Properties:
66 AssemblyVersion - Needed to determine API version used in
67 IsReferenceAssembly - Set if the project is in the ref assm path
70 APIVersion - Major.Minor assembly version for the project
72 <Import Project="$(MSBuildThisFileDirectory)ReferenceAssemblies.targets" Condition="'$(ExcludeReferenceAssembliesImport)'!='true'" />
75 Import the codeAnalysis.targets file to enable analyzer support during build.
76 This should happen before we import the frameworkTargeting.targets because that import leads to computing a default
77 for the CodeAnalysisRuleset unless one is already specified
79 <Import Project="$(MSBuildThisFileDirectory)codeAnalysis.targets" />
82 Import the codeOptimization.targets file to enable profile guided code optimization for managed assemblies.
84 <Import Project="$(MSBuildThisFileDirectory)codeOptimization.targets" />
87 Import the Symbols.targets file to provide access to Symbol Server index/archive tooling.
89 <Import Project="$(MSBuildThisFileDirectory)Symbols.targets" />
92 Import the PublishProduct.targets file for publish tooling like NuGetPush.
94 <Import Project="$(MSBuildThisFileDirectory)PublishProduct.targets" />
97 Import the default target framework targets.
100 TargetFrameworkIdentifier - If not set defaults to .NETPortable
101 TargetFrameworkVersion - If not set defaults to v4.5
102 TargetFrameworkProfile - If not set defaults to Profile7
104 This Imports portable.csharp/visualbasic.targets if .NETPortable is the identifier otherwise it imports csharp/visualbasic.targets
106 <Import Project="$(MSBuildThisFileDirectory)FrameworkTargeting.targets" Condition="'$(ExcludeFrameworkTargetingImport)'!='true'" />
109 Import the default assembly info generation targets
112 GenerateAssemblyInfo - Controls whether or not to generate the assembly info file and defaults to true if not set.
113 AssemblyVersion - If not set defaults to 1.0.0.0 but it is expected to be set in csproj files.
114 CLSCompliant - If not set defaults to true and if it is true then adds the assembly level CLSCompliant(true) attribute.
117 MajorVersion - If not set defaults to 1.
118 MinorVersion - If not set defaults to 0.
119 BuildNumberMajor - If not set defaults to 0.
120 BuildNumberMinor - If not set defaults to 0.
121 AssemblyFileVersion - If not set defaults to $(MajorVersion).$(MinorVersion).$(BuildNumberMajor).$(BuildNumberMinor).
123 BuildNumberTarget - If this property is set it will try to import the file which allows for it to override the properties above.
125 <Import Project="$(MSBuildThisFileDirectory)versioning.targets" Condition="'$(ExcludeVersioningImport)'!='true'" />
127 <Import Project="$(MSBuildThisFileDirectory)Packaging.targets" Condition="'$(ExcludePackagingImport)'!='true' AND '$(MSBuildProjectExtension)' == '.pkgproj'" />
129 <!-- Task to detect the TestNugetRuntimeId of a platform. This target is here to allow both the test build and sync steps to use
130 the same property for asset selection.
132 <UsingTask TaskName="GetTargetMachineInfo" AssemblyFile="$(BuildToolsTaskDir)Microsoft.DotNet.Build.Tasks.dll"/>
133 <Target Name="GetDefaultTestRid">
134 <GetTargetMachineInfo>
135 <Output TaskParameter="RuntimeIdentifier" PropertyName="DefaultTestNugetRuntimeId" />
136 </GetTargetMachineInfo>
137 <!-- On Windows, we always use win7-x64 as the default test RID because the build context,
138 usually 32-bit full-framework MSBuild, is not a good default test context. -->
140 <DefaultTestNugetRuntimeId Condition="$(DefaultTestNugetRuntimeId.StartsWith('win'))">win7-x64</DefaultTestNugetRuntimeId>
141 <TestArchitecture Condition="'$(TestArchitecture)' == ''">x64</TestArchitecture>
142 <TestNugetRuntimeId Condition="'$(TestNugetRuntimeId)' == '' And '$(TestArchitecture)'=='x86'">win7-x86</TestNugetRuntimeId>
143 <TestNugetRuntimeId Condition="'$(TestNugetRuntimeId)' == ''">$(DefaultTestNugetRuntimeId)</TestNugetRuntimeId>
148 <ResolvePkgProjReferencesDependsOn>GetDefaultTestRid;$(ResolvePkgProjReferencesDependsOn)</ResolvePkgProjReferencesDependsOn>
152 Import the default package restore and resolve targets
155 ProjectJson - If not set defaults to $(MSBuildProjectDirectory)\project.json
156 RestorePackages - If not set defaults to the existence of the $(ProjectJson)
157 ResolveNuGetPackages - If not set defaults to the existance of $(ProjectJson)
159 Depends on properties:
160 NugetRestoreCommand - Used to restore the project packages from packages.config
161 DnuRestoreCommand - Used to restore the project packages from project.json
162 PackagesDir - Packages are restored to and resolved from this location
164 Depends on properties set by csharp/visualbasic.targets so needs to be imported after.
166 <Import Project="$(MSBuildThisFileDirectory)packageresolve.targets" Condition="'$(ExcludePackageResolveImport)'!='true'" />
169 Import the optional tooling restore and resolve targets
172 OptionalToolSource - If not set, optional tools are not restored
173 OptionalToolSourceUser - If not set, no authentication is used to access the feed
174 OptionalToolSourcePassword - If not set, no authentication is used to access the feed
176 Depends on properties:
177 DnuRestoreCommand - Used to restore the optional tool packages
178 PackagesDir - Location to resolve optional tool package assets
179 ToolsDir - Location to find optional-tool-runtime project.json
181 <Import Project="$(MSBuildThisFileDirectory)OptionalTooling.targets" />
184 Import the partial facade generation targets
187 GeneratePlatformNotSupportedAssembly - Determines wether to generate not-supported API for this assembly
189 <Import Project="$(MSBuildThisFileDirectory)notsupported.targets" Condition="'$(ExcludePartialFacadesImport)' != 'true'"/>
192 Import the default SR resource generation targets
195 ResourcesSourceOutputDirectory - If not set defaults to $(MSBuildProjectDirectory)\Resources.
196 StringResourcesPath - If not set defaults to $(ResourcesSourceOutputDirectory\Strings.resx if it exists. If the file exists
197 then the targets generates the strongly typed $(ResourcesSourceOutputDirectory)\SR.cs/vb file based on resource strings.
198 OmitResources - If set to true will skip resource inclusion even if StringResourcesPath exists.
200 <Import Project="$(MSBuildThisFileDirectory)resources.targets" Condition="'$(ExcludeResourcesImport)'!='true'" />
203 Import the localization target
205 <Import Project="$(MSBuildThisFileDirectory)localization.targets" Condition="'$(ExcludeLocalizationImport)'!='true'" />
208 Import the partial facade generation targets
211 IsPartialFacadeAssembly - Determines whether the partial facade generation targets will be as a post-processing step on the
212 assembly. Also invokes special logic for determining References.
214 <Import Project="$(MSBuildThisFileDirectory)partialfacades.targets" Condition="'$(ExcludePartialFacadesImport)' != 'true'"/>
216 <!-- Import the ApiCompat targets. -->
217 <Import Project="$(MSBuildThisFileDirectory)ApiCompat.targets" />
220 Import the contract resolution targets
223 AssemblyName - Needed to determine which contract name to map to
224 AssemblyVersion - Needed to determine which contract version to map to
226 <Import Project="$(MSBuildThisFileDirectory)resolveContract.targets" Condition="'$(ExcludeResolveContractImport)' != 'true'"/>
228 Import the default signing targets which will setup the authenticode properties and do OpenSourceSigning
231 SkipSigning - For projects that want to opt-out of strong name signing the can set this to true.
233 <Import Project="$(MSBuildThisFileDirectory)sign.targets" Condition="'$(ExcludeSigningImport)'!='true'" />
236 Import the tests.targets which controls the publishing and running of the tests, including code coverage options.
239 RunTestsForProject - Usually set at the project level to disable the tests for a single project.
240 CoverageEnabledForProject - Usually set at the project level to disable code coverage for a single project.
241 SkipTests - Usually set at the root level for builds that want to disable all the tests.
242 ProjectJson - If not set defaults to $(MSBuildProjectDirectory)\project.json
243 CopyTestToTestDirectory - If not set defaults to $(IsTestProject)
245 Depends on Properties:
246 TestPath - Controls the root path from where the test assets are published and run from.
247 NugetRestoreCommand - Used to restore the test runtime package
248 DnuRestoreCommand - Used to restore the project packages from project.json
249 PackagesDir - Packages are restored to and resolved from this location
251 <Import Project="$(MSBuildThisFileDirectory)tests.targets" Condition="'$(IsTestProject)'=='true' and '$(ExcludeTestsImport)'!='true'"/>
254 Import the PackageLibs.targets which exposes targets from library projects to report what
255 assets they contribute to nuget packages.
257 PackageTargetFramework - Target moniker to use for harvested dependencies.
258 If PackageTargetPath is not set, PackageTargetPath will be constructed
259 based on PackageTargetFramework.
262 PackageSourcePath - Source path to the built output to be packaged, default is $(TargetPath)
264 IsReferenceAssembly - true if this project is a reference assembly.
265 PackageTargetPath - Destination subpath in the package at which all assets from this project
266 should be located. Default is lib\$(PackageTargetFramework) for implementation
267 assemblies, ref\$(PackageTargetFramework) for reference assemblies. Can be
268 overridden. When overridding also override PackageTargetFramework.
269 PackageTargetRuntime - Runtime id to use for harvested dependencies, default is none.
270 Can be overridden. If PackageTargetRuntime is overridden and PackageTargetPath
271 is not, PackageTargetPath will be constructed based on PackageTargetRuntime.
272 @(PackageDestination) - List of items with TargetFramework metadata that represent destination
273 subpaths in the package at which all assets from this project should be
274 located. When specified takes precedence over PackageTargetPath &
275 PackageTargetFramework.
276 DocumentationFile - location of xml doc produced by this project.
277 XmlDocFileRoot - location to pre-authored localized xml doc files
278 PackageIncludeDocs - true to include the docs next to this project's ouput. Default
279 is true for reference assemblies, false for implementation.
281 <Import Project="$(MSBuildThisFileDirectory)PackageLibs.targets" Condition="'$(ExcludePackageLibsImport)'!='true'"/>
283 <Target Name="CheckDesignTime">
285 Visual Studio does a number of background builds to do a variety of tasks such as resolving references and preparing for intellisense.
286 These are called "design time" builds. You can only determine this state within a target as the properties VS sets are added at build time.
288 To see design time logs set TRACEDESIGNTIME=true before launching Visual Studio. Logs will go to %TEMP%.
290 Note that the existing $(DesignTimeBuild) is not set for all background builds.
293 <VSDesignTimeBuild Condition="'$(BuildingInsideVisualStudio)'=='true' and '$(BuildingOutOfProcess)'=='false'">true</VSDesignTimeBuild>
298 import the MicroBuild boot-strapper project (only relevant for shipping binaries)
299 NOTE: we import this at the end as it will override some dummy targets (e.g. SignFiles)
301 <Import Project="$(MSBuildThisFileDirectory)MicroBuild.Core.targets" Condition="Exists('$(MSBuildThisFileDirectory)MicroBuild.Core.targets') and '$(IsTestProject)' != 'true'" />
304 Providing a definition for __BlockReflectionAttribute in an assembly is a signal to the .NET Native toolchain
305 to remove the metadata for all non-public APIs. This both reduces size and disables private reflection on those
306 APIs in libraries that include this. The attribute can also be applied to individual public APIs to similarly block them.
309 <BlockReflectionAttribute Condition="'$(BlockReflectionAttribute)' == '' and '$(UWPCompatible)' == 'true' and '$(IsTestProject)' != 'true'">true</BlockReflectionAttribute>
310 <BlockReflectionAttribute Condition="'$(MSBuildProjectExtension)' != '.csproj'">false</BlockReflectionAttribute>
313 <PropertyGroup Condition="'$(BlockReflectionAttribute)'=='true'">
314 <CoreCompileDependsOn>$(CoreCompileDependsOn);AddBlockReflectionAttribute</CoreCompileDependsOn>
315 <BlockReflectionAtributeFile>$(MSBuildThisFileDirectory)/BlockReflectionAttribute.cs</BlockReflectionAtributeFile>
318 <Target Name="AddBlockReflectionAttribute" >
320 <Compile Include="$(BlockReflectionAtributeFile)" />
324 <Import Project="$(CustomAfterBuildCommonTargets)" Condition="Exists('$(CustomAfterBuildCommonTargets)')"/>