Reputation: 669
When I try to use msbuild properties like $(TargetFrameworkSDKToolsDirectory)
or $(SDKToolsPath)
in a custom build target for a .NETStandard libary, these properties are empty/not defined. Using the exact same build target for a .NET 4.6.2 Assembly works fine however. Are there .targets files I need to manually include for .NETStandard or what else could I be missing?
Importing $(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props
does not help. I am using Visual Studio 2017 Community.
*.csproj for .NETStandard lib:
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<TargetFramework>netstandard1.4</TargetFramework>
<RootNamespace>MyNamespace</RootNamespace>
<AllowUnsafeBlocks>True</AllowUnsafeBlocks>
</PropertyGroup>
<!--
ItemGroups for files and references
-->
<Target Name="PropsTest" BeforeTargets="CoreCompile">
<!-- Prints: "Path: " -->
<Message Text="Path: $(TargetFrameworkSDKToolsDirectory)" Importance="high" />
</Target>
</Project>
*.csproj for .NET 4.6.2 app:
<?xml version="1.0" encoding="utf-8"?>
<Project ToolsVersion="15.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<Import Project="$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props" Condition="Exists('$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props')" />
<PropertyGroup>
<Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
<Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
<ProjectGuid>{73E77BB7-D3F9-4797-B62D-24666D1132EF}</ProjectGuid>
<OutputType>Exe</OutputType>
<RootNamespace>SamplesConsole</RootNamespace>
<AssemblyName>SamplesConsole</AssemblyName>
<TargetFrameworkVersion>v4.6.2</TargetFrameworkVersion>
<FileAlignment>512</FileAlignment>
<AutoGenerateBindingRedirects>true</AutoGenerateBindingRedirects>
<TargetFrameworkProfile />
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
<PlatformTarget>AnyCPU</PlatformTarget>
<DebugSymbols>true</DebugSymbols>
<DebugType>full</DebugType>
<Optimize>false</Optimize>
<OutputPath>bin\Debug\</OutputPath>
<DefineConstants>DEBUG;TRACE</DefineConstants>
<ErrorReport>prompt</ErrorReport>
<WarningLevel>4</WarningLevel>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' ">
<PlatformTarget>AnyCPU</PlatformTarget>
<DebugType>pdbonly</DebugType>
<Optimize>true</Optimize>
<OutputPath>bin\Release\</OutputPath>
<DefineConstants>TRACE</DefineConstants>
<ErrorReport>prompt</ErrorReport>
<WarningLevel>4</WarningLevel>
</PropertyGroup>
<!--
ItemGroups for files and references
-->
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
<Target Name="PropsTest" BeforeTargets="CoreCompile">
<!-- Prints: "Path: C:\Program Files (x86)\Microsoft SDKs\Windows\v10.0A\bin\NETFX 4.6.1 Tools\" -->
<Message Text="Path: $(TargetFrameworkSDKToolsDirectory)" Importance="high" />
</Target>
</Project>
Upvotes: 1
Views: 1712
Reputation: 121
For the .NET 4.6.2 Library the TargetFrameworkSDKToolsDirectory property is set by Microsoft.NETFramework.CurrentVersion.props.
It's set with either $(SDK35ToolsPath) or $(SDK40ToolsPath).
SDK40ToolsPath property is available in a .NET Standard Library build even though TargetFrameworkSDKToolsDirectory is not.
Upvotes: 3