2 ***********************************************************************************************
\r
3 Microsoft.CSharp.CurrentVersion.targets
\r
5 WARNING: DO NOT MODIFY this file unless you are knowledgeable about MSBuild and have
\r
6 created a backup copy. Incorrect changes to this file will make it
\r
7 impossible to load or build your projects from the command-line or the IDE.
\r
9 This file defines the steps in the standard build process specific for C# .NET projects.
\r
10 For example, it contains the step that actually calls the C# compiler. The remainder
\r
11 of the build process is defined in Microsoft.Common.targets, which is imported by
\r
14 Copyright (C) Microsoft Corporation. All rights reserved.
\r
15 ***********************************************************************************************
\r
18 <Project xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
\r
21 <ImportByWildcardBeforeMicrosoftCSharpTargets Condition="'$(ImportByWildcardBeforeMicrosoftCSharpTargets)' == ''">true</ImportByWildcardBeforeMicrosoftCSharpTargets>
\r
22 <ImportByWildcardAfterMicrosoftCSharpTargets Condition="'$(ImportByWildcardAfterMicrosoftCSharpTargets)' == ''">true</ImportByWildcardAfterMicrosoftCSharpTargets>
\r
23 <ImportUserLocationsByWildcardBeforeMicrosoftCSharpTargets Condition="'$(ImportUserLocationsByWildcardBeforeMicrosoftCSharpTargets)' == ''">true</ImportUserLocationsByWildcardBeforeMicrosoftCSharpTargets>
\r
24 <ImportUserLocationsByWildcardAfterMicrosoftCSharpTargets Condition="'$(ImportUserLocationsByWildcardAfterMicrosoftCSharpTargets)' == ''">true</ImportUserLocationsByWildcardAfterMicrosoftCSharpTargets>
\r
27 <Import Project="$(MSBuildUserExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.CSharp.targets\ImportBefore\*" Condition="'$(ImportUserLocationsByWildcardBeforeMicrosoftCSharpTargets)' == 'true' and exists('$(MSBuildUserExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.CSharp.targets\ImportBefore')"/>
\r
28 <Import Project="$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.CSharp.targets\ImportBefore\*" Condition="'$(ImportByWildcardBeforeMicrosoftCSharpTargets)' == 'true' and exists('$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.CSharp.targets\ImportBefore')"/>
\r
31 <CustomBeforeMicrosoftCSharpTargets Condition="'$(CustomBeforeMicrosoftCSharpTargets)'==''">$(MSBuildExtensionsPath)\v$(MSBuildToolsVersion)\Custom.Before.Microsoft.CSharp.targets</CustomBeforeMicrosoftCSharpTargets>
\r
32 <CustomAfterMicrosoftCSharpTargets Condition="'$(CustomAfterMicrosoftCSharpTargets)'==''">$(MSBuildExtensionsPath)\v$(MSBuildToolsVersion)\Custom.After.Microsoft.CSharp.targets</CustomAfterMicrosoftCSharpTargets>
\r
35 <Import Project="$(CustomBeforeMicrosoftCSharpTargets)" Condition="'$(CustomBeforeMicrosoftCSharpTargets)' != '' and Exists('$(CustomBeforeMicrosoftCSharpTargets)')" />
\r
38 <MSBuildAllProjects>$(MSBuildAllProjects);$(MSBuildThisFileFullPath)</MSBuildAllProjects>
\r
39 <DefaultLanguageSourceExtension>.cs</DefaultLanguageSourceExtension>
\r
40 <Language>C#</Language>
\r
41 <TargetRuntime>Managed</TargetRuntime>
\r
42 <AlwaysUseNumericalSuffixInItemNames>true</AlwaysUseNumericalSuffixInItemNames>
\r
43 <DefineCommonItemSchemas Condition=" '$(DefineCommonItemSchemas)' == '' ">true</DefineCommonItemSchemas>
\r
44 <DefineCommonReferenceSchemas Condition=" '$(DefineCommonReferenceSchemas)' == '' ">true</DefineCommonReferenceSchemas>
\r
45 <DefineCommonCapabilities Condition=" '$(DefineCommonCapabilities)' == '' ">true</DefineCommonCapabilities>
\r
46 <SynthesizeLinkMetadata Condition=" '$(SynthesizeLinkMetadata)' == '' and '$(HasSharedItems)' == 'true' ">true</SynthesizeLinkMetadata>
\r
47 <DefaultProjectTypeGuid Condition=" '$(DefaultProjectTypeGuid)' == '' ">{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}</DefaultProjectTypeGuid>
\r
48 <AppDesignerFolder Condition="'$(AppDesignerFolder)' == ''">Properties</AppDesignerFolder>
\r
52 <PropertyPageSchema Include="$(CommonXamlResourcesDirectory)CSharp.ProjectItemsSchema.xaml;"/>
\r
53 <PropertyPageSchema Include="$(CommonXamlResourcesDirectory)CSharp.xaml;">
\r
54 <Context>File</Context>
\r
55 </PropertyPageSchema>
\r
56 <PropertyPageSchema Include="$(CommonXamlResourcesDirectory)CSharp.BrowseObject.xaml;">
\r
57 <Context>BrowseObject</Context>
\r
58 </PropertyPageSchema>
\r
60 <ProjectCapability Include="CSharp;Managed"/>
\r
63 <ItemGroup Condition=" '$(DefineCommonCapabilities)' == 'true' ">
\r
64 <ProjectCapability Include="ReferencesFolder;LanguageService" />
\r
65 <ProjectCapability Include="ProjectConfigurationsInferredFromUsage" />
\r
69 The CreateManifestResourceNames target create the manifest resource names from the .RESX
\r
73 @(EmbeddedResource) - The list of EmbeddedResource items that have been pre-processed to add metadata about resource type
\r
74 Expected Metadata "Type" can either be "Resx" or "Non-Resx"
\r
77 @(EmbeddedResource) - EmbeddedResource items with metadata
\r
79 For C# applications the transformation is like:
\r
81 Resources1.resx => RootNamespace.Resources1 => Build into main assembly
\r
82 SubFolder\Resources1.resx => RootNamespace.SubFolder.Resources1 => Build into main assembly
\r
83 Resources1.fr.resx => RootNamespace.Resources1.fr => Build into satellite assembly
\r
84 Resources1.notaculture.resx => RootNamespace.Resources1.notaculture => Build into main assembly
\r
86 For other project systems, this transformation may be different.
\r
89 <CreateManifestResourceNamesDependsOn></CreateManifestResourceNamesDependsOn>
\r
92 Name="CreateManifestResourceNames"
\r
93 Condition="'@(EmbeddedResource)' != ''"
\r
94 DependsOnTargets="$(CreateManifestResourceNamesDependsOn)"
\r
98 <_Temporary Remove="@(_Temporary)" />
\r
101 <!-- Create manifest names for culture and non-culture Resx files, and for non-culture Non-Resx resources -->
\r
102 <CreateCSharpManifestResourceName
\r
103 ResourceFiles="@(EmbeddedResource)"
\r
104 RootNamespace="$(RootNamespace)"
\r
105 Condition="'%(EmbeddedResource.ManifestResourceName)' == '' and ('%(EmbeddedResource.WithCulture)' == 'false' or '%(EmbeddedResource.Type)' == 'Resx')">
\r
107 <Output TaskParameter="ResourceFilesWithManifestResourceNames" ItemName="_Temporary" />
\r
109 </CreateCSharpManifestResourceName>
\r
111 <!-- Create manifest names for all culture non-resx resources -->
\r
112 <CreateCSharpManifestResourceName
\r
113 ResourceFiles="@(EmbeddedResource)"
\r
114 RootNamespace="$(RootNamespace)"
\r
115 PrependCultureAsDirectory="false"
\r
116 Condition="'%(EmbeddedResource.ManifestResourceName)' == '' and '%(EmbeddedResource.WithCulture)' == 'true' and '%(EmbeddedResource.Type)' == 'Non-Resx'">
\r
118 <Output TaskParameter="ResourceFilesWithManifestResourceNames" ItemName="_Temporary" />
\r
120 </CreateCSharpManifestResourceName>
\r
123 <EmbeddedResource Remove="@(EmbeddedResource)" Condition="'%(EmbeddedResource.ManifestResourceName)' == ''"/>
\r
124 <EmbeddedResource Include="@(_Temporary)" />
\r
125 <_Temporary Remove="@(_Temporary)" />
\r
131 Name="ResolveCodeAnalysisRuleSet"
\r
132 Condition="'$(CodeAnalysisRuleSet)' != ''"
\r
135 <ResolveCodeAnalysisRuleSet
\r
136 CodeAnalysisRuleSet="$(CodeAnalysisRuleSet)"
\r
137 CodeAnalysisRuleSetDirectories="$(CodeAnalysisRuleSetDirectories)"
\r
138 MSBuildProjectDirectory="$(MSBuildProjectDirectory)">
\r
140 <Output TaskParameter="ResolvedCodeAnalysisRuleSet" PropertyName="ResolvedCodeAnalysisRuleSet" />
\r
142 </ResolveCodeAnalysisRuleSet>
\r
147 <!-- Activate CPS projects to track folder names in namespace. -->
\r
148 <ProjectCapability Include="RelativePathDerivedDefaultNamespace"/>
\r
152 <!-- Provide a facility to override UseHostCompilerIfAvailable-->
\r
153 <UseHostCompilerIfAvailable Condition=" '$(UseHostCompilerIfAvailable)' == ''">true</UseHostCompilerIfAvailable>
\r
157 <DocFileItem Include="$(DocumentationFile)" Condition="'$(DocumentationFile)'!=''"/>
\r
160 <ItemGroup Condition="'$(_DebugSymbolsProduced)' == 'true' and '$(PdbFile)' != ''">
\r
161 <_DebugSymbolsIntermediatePathTemporary Include="$(PdbFile)"/>
\r
162 <!-- Add any missing .pdb extension, as the compiler does -->
\r
163 <_DebugSymbolsIntermediatePath Include="@(_DebugSymbolsIntermediatePathTemporary->'%(RootDir)%(Directory)%(Filename).pdb')"/>
\r
167 <CoreCompileDependsOn>_ComputeNonExistentFileProperty;ResolveCodeAnalysisRuleSet</CoreCompileDependsOn>
\r
168 <ExportWinMDFile Condition="'$(ExportWinMDFile)' == '' and '$(OutputType)' == 'WinMDObj'">true</ExportWinMDFile>
\r
172 The XamlPreCompile target must remain identical to
\r
173 the CoreCompile target in Microsoft.CSharp.Core.targets.
\r
174 Any updates to one must be made to the other.
\r
177 Name="XamlPreCompile"
\r
178 Inputs="$(MSBuildAllProjects);
\r
180 @(_CoreCompileResourceInputs);
\r
181 $(ApplicationIcon);
\r
182 $(AssemblyOriginatorKeyFile);
\r
184 @(CompiledLicenseFile);
\r
186 @(EmbeddedDocumentation);
\r
189 @(CustomAdditionalCompileInputs);
\r
191 @(ApplicationDefinition);
\r
192 $(ResolvedCodeAnalysisRuleSet)"
\r
194 Outputs="@(DocFileItem);
\r
195 @(XamlIntermediateAssembly);
\r
196 @(_DebugSymbolsIntermediatePath);
\r
197 $(NonExistentFile);
\r
198 @(CustomAdditionalCompileOutputs)"
\r
199 Condition="'@(Page)' != '' Or '@(ApplicationDefinition)' != ''"
\r
201 DependsOnTargets="$(CoreCompileDependsOn)"
\r
203 <!-- These two compiler warnings are raised when a reference is bound to a different version
\r
204 than specified in the assembly reference version number. MSBuild raises the same warning in this case,
\r
205 so the compiler warning would be redundant. -->
\r
206 <PropertyGroup Condition="('$(TargetFrameworkVersion)' != 'v1.0') and ('$(TargetFrameworkVersion)' != 'v1.1')">
\r
207 <NoWarn>$(NoWarn);1701;1702</NoWarn>
\r
211 <!-- To match historical behavior, when inside VS11+ disable the warning from csc.exe indicating that no sources were passed in-->
\r
212 <NoWarn Condition=" '$(BuildingInsideVisualStudio)' == 'true' and '$(VisualStudioVersion)' != '' and '$(VisualStudioVersion)' > '10.0' ">$(NoWarn);2008</NoWarn>
\r
215 <ItemGroup Condition="'$(TargetingClr2Framework)'=='true'">
\r
217 <EmbedInteropTypes/>
\r
222 <!-- If the user has specified AppConfigForCompiler, we'll use it. If they have not, but they set UseAppConfigForCompiler,
\r
223 then we'll use AppConfig -->
\r
224 <AppConfigForCompiler Condition="'$(AppConfigForCompiler)' == '' and '$(UseAppConfigForCompiler)' == 'true'">$(AppConfig)</AppConfigForCompiler>
\r
226 <!-- If we are targeting winmdobj we want to specifically the pdbFile property since we do not want it to collide with the output of winmdexp-->
\r
227 <PdbFile Condition="'$(PdbFile)' == '' and '$(OutputType)' == 'winmdobj' and '$(_DebugSymbolsProduced)' == 'true'">$(IntermediateOutputPath)$(TargetName).compile.pdb</PdbFile>
\r
230 <!-- Prefer32Bit was introduced in .NET 4.5. Set it to false if we are targeting 4.0 -->
\r
231 <PropertyGroup Condition="('$(TargetFrameworkVersion)' == 'v4.0')">
\r
232 <Prefer32Bit>false</Prefer32Bit>
\r
235 <ItemGroup Condition="('$(AdditionalFileItemNames)' != '')">
\r
236 <AdditionalFileItems Include="$(AdditionalFileItemNames)" />
\r
237 <AdditionalFiles Include="@(%(AdditionalFileItems.Identity))" />
\r
240 <!-- Don't run analyzers for Csc task on XamlPrecompile pass, we only want to run them on core compile. -->
\r
241 <!-- Analyzers="@(Analyzer)" -->
\r
243 <PropertyGroup Condition="'$(UseSharedCompilation)' == ''">
\r
244 <UseSharedCompilation>true</UseSharedCompilation>
\r
247 <!-- Condition is to filter out the _CoreCompileResourceInputs so that it doesn't pass in culture resources to the compiler -->
\r
248 <Csc Condition=" '%(_CoreCompileResourceInputs.WithCulture)' != 'true' "
\r
249 AdditionalLibPaths="$(AdditionalLibPaths)"
\r
250 AddModules="@(AddModules)"
\r
251 AdditionalFiles="@(AdditionalFiles)"
\r
252 AllowUnsafeBlocks="$(AllowUnsafeBlocks)"
\r
253 ApplicationConfiguration="$(AppConfigForCompiler)"
\r
254 BaseAddress="$(BaseAddress)"
\r
255 CheckForOverflowUnderflow="$(CheckForOverflowUnderflow)"
\r
256 CodeAnalysisRuleSet="$(ResolvedCodeAnalysisRuleSet)"
\r
257 CodePage="$(CodePage)"
\r
258 DebugType="$(DebugType)"
\r
259 DefineConstants="$(DefineConstants)"
\r
260 DelaySign="$(DelaySign)"
\r
261 DisabledWarnings="$(NoWarn)"
\r
262 DocumentationFile="@(DocFileItem)"
\r
263 EmitDebugInformation="$(DebugSymbols)"
\r
264 EnvironmentVariables="$(CscEnvironment)"
\r
265 ErrorEndLocation="$(ErrorEndLocation)"
\r
266 ErrorLog="$(ErrorLog)"
\r
267 ErrorReport="$(ErrorReport)"
\r
268 FileAlignment="$(FileAlignment)"
\r
269 GenerateFullPaths="$(GenerateFullPaths)"
\r
270 HighEntropyVA="$(HighEntropyVA)"
\r
271 KeyContainer="$(KeyContainerName)"
\r
272 KeyFile="$(KeyOriginatorFile)"
\r
273 LangVersion="$(LangVersion)"
\r
274 LinkResources="@(LinkResource)"
\r
275 MainEntryPoint="$(StartupObject)"
\r
276 ModuleAssemblyName="$(ModuleAssemblyName)"
\r
279 NoStandardLib="$(NoCompilerStandardLib)"
\r
280 NoWin32Manifest="$(NoWin32Manifest)"
\r
281 Optimize="$(Optimize)"
\r
282 OutputAssembly="@(XamlIntermediateAssembly)"
\r
283 PdbFile="$(PdbFile)"
\r
284 Platform="$(PlatformTarget)"
\r
285 Prefer32Bit="$(Prefer32Bit)"
\r
286 PreferredUILang="$(PreferredUILang)"
\r
287 References="@(ReferencePath)"
\r
288 ReportAnalyzer="$(ReportAnalyzer)"
\r
289 Resources="@(_CoreCompileResourceInputs);@(CompiledLicenseFile)"
\r
290 ResponseFiles="$(CompilerResponseFile)"
\r
291 Sources="@(Compile)"
\r
292 SubsystemVersion="$(SubsystemVersion)"
\r
293 TargetType="$(OutputType)"
\r
294 ToolExe="$(CscToolExe)"
\r
295 ToolPath="$(CscToolPath)"
\r
296 TreatWarningsAsErrors="$(TreatWarningsAsErrors)"
\r
297 UseHostCompilerIfAvailable="$(UseHostCompilerIfAvailable)"
\r
298 UseSharedCompilation="$(UseSharedCompilation)"
\r
299 Utf8Output="$(Utf8Output)"
\r
300 VsSessionGuid="$(VsSessionGuid)"
\r
301 WarningLevel="$(WarningLevel)"
\r
302 WarningsAsErrors="$(WarningsAsErrors)"
\r
303 WarningsNotAsErrors="$(WarningsNotAsErrors)"
\r
304 Win32Icon="$(ApplicationIcon)"
\r
305 Win32Manifest="$(Win32Manifest)"
\r
306 Win32Resource="$(Win32Resource)"
\r
309 <!-- Only Applicable to the regular CoreCompile:
\r
311 <_CoreCompileResourceInputs Remove="@(_CoreCompileResourceInputs)" />
\r
314 <CallTarget Targets="$(TargetsTriggeredByCompilation)" Condition="'$(TargetsTriggeredByCompilation)' != ''"/>
\r
316 <OnError Condition="'$(OnXamlPreCompileErrorTarget)' != ''" ExecuteTargets="$(OnXamlPreCompileErrorTarget)" />
\r
320 <CSharpCoreTargetsPath Condition="'$(CSharpCoreTargetsPath)' == ''">$(RoslynTargetsPath)\Microsoft.CSharp.Core.targets</CSharpCoreTargetsPath>
\r
323 <Import Project="$(CSharpCoreTargetsPath)" />
\r
325 <!-- Import design time targets for Roslyn Project System. These are only available if Visual Studio is installed. -->
\r
326 <!-- Import design time targets before the common targets, which import targets from Nuget. -->
\r
328 <CSharpDesignTimeTargetsPath Condition="'$(CSharpDesignTimeTargetsPath)'==''">$(MSBuildExtensionsPath)\Microsoft\VisualStudio\Managed\Microsoft.CSharp.DesignTime.targets</CSharpDesignTimeTargetsPath>
\r
330 <Import Project="$(CSharpDesignTimeTargetsPath)" Condition="'$(CSharpDesignTimeTargetsPath)' != '' and Exists('$(CSharpDesignTimeTargetsPath)')" />
\r
332 <Import Project="Microsoft.Common.targets" />
\r
333 <Import Project="$(MSBuildToolsPath)\Microsoft.ServiceModel.targets" Condition="('$(TargetFrameworkVersion)' != 'v2.0' and '$(TargetFrameworkVersion)' != 'v3.0' and '$(TargetFrameworkVersion)' != 'v3.5') and Exists('$(MSBuildToolsPath)\Microsoft.ServiceModel.targets')"/>
\r
335 <Target Name="_SetTargetFrameworkMonikerAttribute" BeforeTargets="GenerateTargetFrameworkMonikerAttribute">
\r
337 <TargetFrameworkMonikerAssemblyAttributeText Condition="'$(TargetFrameworkMoniker)' != '' and '$(TargetingClr2Framework)' != 'true'">
\r
338 // <autogenerated />
\r
340 using System.Reflection%3b
\r
341 [assembly: global::System.Runtime.Versioning.TargetFrameworkAttribute("$(TargetFrameworkMoniker)", FrameworkDisplayName = "$(TargetFrameworkMonikerDisplayName)")]
\r
342 </TargetFrameworkMonikerAssemblyAttributeText>
\r
347 <Utf8Output Condition="'$(Utf8Output)' == ''">true</Utf8Output>
\r
349 <!-- NoCompilerStandardLib maps to the compiler's /nostdlib option. By default we always
\r
350 want that switch to be passed to the compiler so that either we or the user
\r
351 provides the references
\r
352 NoStdLib on the other hand indicates that the user doesn't want standard references
\r
353 so only if NoStdLib isn't set to true, will we provide the standard references
\r
355 <NoCompilerStandardLib Condition=" '$(NoCompilerStandardLib)' == '' ">true</NoCompilerStandardLib>
\r
357 <ErrorEndLocation Condition="'$(BuildingInsideVisualStudio)' == 'true' and '$(ErrorEndLocation)' == ''">true</ErrorEndLocation>
\r
359 <!-- When building inside VS, by default use the same language for compiler messages as VS itself does. -->
\r
360 <PreferredUILang Condition="'$(BuildingInsideVisualStudio)' == 'true' and '$(PreferredUILang)' == ''">$([System.Globalization.CultureInfo]::CurrentUICulture.Name)</PreferredUILang>
\r
363 <!-- Add any "automatic" compiler references that need to be resolved when NoCompilerStandardLib is set
\r
364 but the user hasn't told us to not include standard references -->
\r
365 <ItemGroup Condition=" '$(NoCompilerStandardLib)' == 'true' and '$(NoStdLib)' != 'true' ">
\r
366 <!-- Note that unlike VB, C# does not automatically locate System.dll as a "standard library"
\r
367 instead the reference is always passed from the project. Also, for mscorlib.dll
\r
368 we need to provide the explicit location in order to maintain the correct behaviour
\r
370 <_ExplicitReference Include="$(FrameworkPathOverride)\mscorlib.dll" />
\r
373 <Import Project="$(CustomAfterMicrosoftCSharpTargets)" Condition="'$(CustomAfterMicrosoftCSharpTargets)' != '' and Exists('$(CustomAfterMicrosoftCSharpTargets)')" />
\r
375 <Import Project="$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.CSharp.targets\ImportAfter\*" Condition="'$(ImportByWildcardAfterMicrosoftCSharpTargets)' == 'true' and exists('$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.CSharp.targets\ImportAfter')"/>
\r
376 <Import Project="$(MSBuildUserExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.CSharp.targets\ImportAfter\*" Condition="'$(ImportUserLocationsByWildcardAfterMicrosoftCSharpTargets)' == 'true' and exists('$(MSBuildUserExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.CSharp.targets\ImportAfter')"/>
\r