$(TargetFrameworkSDKToolsDirectory)
または$(SDKToolsPath)
のようなmsbuildプロパティを.NETスタンダードライブラリのカスタムビルドターゲットに使用しようとすると、これらのプロパティは空であり/定義されていません。しかし、.NET 4.6.2アセンブリとまったく同じビルドターゲットを使用すると、うまく動作します。 .NETStandardに手動で含める必要がある.targetsファイルがありますか、それ以外のものはありますか?.NETスタンダードライブラリプロジェクトのMSBuildプロパティ
$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props
のインポートは役に立ちません。私はVisual Studio 2017コミュニティを使用しています。
* .csproj .NETStandard libにのために:*は、.NET 4.6.2アプリを.csproj
<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>
:.NET 4.6.2ライブラリの
<?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>
.NETスタンダードプロジェクトは、iOS、Android、Linuxなどのプラットフォームターゲットと互換性があると考えられています.Windows SDKを使用して何かをしたいと思っても意味がありません。 XY質問を避けてください。 –
具体的には、ildasm/ilasmを使用します。それらを使用する別の方法はありますか?この機能は他のプラットフォームでも利用できるはずです。また、「XY質問を避ける」とはどういう意味ですか? – ArgusMagnus
さて、私はXY質問が何であるか知っています(https://meta.stackexchange.com/questions/66377/what-is-the-xy-problem)。どのような不名誉な名前...私はこの質問を削除するか、私と同じ(愚かな)アプローチを試みる他人のために残すべきですか? – ArgusMagnus