Skip to content

Commit 6d7c59e

Browse files
authored
Only default LanguageTargets for projects that the SDK doesn't handle. (#45)
#43 caused a regression for CSharp and VisualBasic projects by attempting to default `LanguageTargets`. However, the property is set too early to work properly. We can only set `LanguageTargets` if its not going to be set by the .NET SDK. Fixes #44
1 parent 354d31f commit 6d7c59e

File tree

1 file changed

+7
-4
lines changed

1 file changed

+7
-4
lines changed

src/NoTargets/Sdk/Sdk.targets

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -7,12 +7,15 @@
77
<Project DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
88

99
<!--
10-
Setup LanguageTargets to include Microsoft.Common.targets
11-
Normally Microsoft.Common.targets is imported via the Language specific targets, but the
12-
NoTargets SDK does not have any "language", so we import the common targets directly
10+
Set LanguageTargets to Microsoft.Common.targets for any project that the SDK won't (.proj, .noproj, etc)
11+
https://github.com/dotnet/sdk/blob/50ddfbb91be94d068514e8f4b0ce1052156364a0/src/Tasks/Microsoft.NET.Build.Tasks/sdk/Sdk.targets#L28
12+
13+
We can't default LanguageTargets it is set in the SDK and immediately imported. So we can only default
14+
it if we know the SDK won't. Projects probably won't load in Visual Studio but will build from the
15+
command-line just fine.
1316
-->
1417
<PropertyGroup>
15-
<LanguageTargets Condition="'$(LanguageTargets)' == ''">$(MSBuildToolsPath)\Microsoft.Common.targets</LanguageTargets>
18+
<LanguageTargets Condition=" '$(LanguageTargets)' == '' And '$(MSBuildProjectExtension)' != '.csproj' And '$(MSBuildProjectExtension)' != '.vbproj' And '$(MSBuildProjectExtension)' != '.fsproj' ">$(MSBuildToolsPath)\Microsoft.Common.targets</LanguageTargets>
1619
</PropertyGroup>
1720

1821
<Import Project="$(CustomBeforeNoTargets)" Condition="'$(CustomBeforeNoTargets)' != '' and Exists('$(CustomBeforeNoTargets)')" />

0 commit comments

Comments
 (0)