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