Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Workaround for WPF temp project not importing NuGet props/targets files #1581

Merged
merged 2 commits into from
Dec 14, 2018
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,8 @@
</PropertyGroup>

<PropertyGroup>
<_NuGetRepackAssembly Condition="'$(MSBuildRuntimeType)' != 'Core'">$(NuGetPackageRoot)roslyntools.nugetrepack.buildtasks\$(RoslynToolsNuGetRepackVersion)\tools\net461\RoslynTools.NuGetRepack.BuildTasks.dll</_NuGetRepackAssembly>
<_NuGetRepackAssembly Condition="'$(MSBuildRuntimeType)' == 'Core'">$(NuGetPackageRoot)roslyntools.nugetrepack.buildtasks\$(RoslynToolsNuGetRepackVersion)\tools\netcoreapp2.0\RoslynTools.NuGetRepack.BuildTasks.dll</_NuGetRepackAssembly>
<_NuGetRepackAssembly Condition="'$(MSBuildRuntimeType)' != 'Core'">$(NuGetPackageRoot)roslyntools.nugetrepack.buildtasks\$(RoslynToolsNuGetRepackVersion)\tools\net472\RoslynTools.NuGetRepack.BuildTasks.dll</_NuGetRepackAssembly>
<_NuGetRepackAssembly Condition="'$(MSBuildRuntimeType)' == 'Core'">$(NuGetPackageRoot)roslyntools.nugetrepack.buildtasks\$(RoslynToolsNuGetRepackVersion)\tools\netcoreapp2.1\RoslynTools.NuGetRepack.BuildTasks.dll</_NuGetRepackAssembly>
</PropertyGroup>

<UsingTask TaskName="Roslyn.Tools.UpdatePackageVersionTask" AssemblyFile="$(_NuGetRepackAssembly)" />
Expand Down
5 changes: 5 additions & 0 deletions src/Microsoft.DotNet.Arcade.Sdk/tools/Imports.targets
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,11 @@
<MSBuildAllProjects>$(MSBuildAllProjects);$(MSBuildThisFileFullPath)</MSBuildAllProjects>
</PropertyGroup>

<!--
Import NuGet targets to WPF temp projects (workaround for https://github.com/dotnet/sourcelink/issues/91)
-->
<Import Project="$(_WpfTempProjectNuGetFilePathNoExt).targets" Condition="'$(_WpfTempProjectNuGetFilePathNoExt)' != '' and Exists('$(_WpfTempProjectNuGetFilePathNoExt).targets')"/>

<PropertyGroup>
<DeployProjectOutput Condition="'$(DeployProjectOutput)' == ''">$(__DeployProjectOutput)</DeployProjectOutput>

Expand Down
10 changes: 7 additions & 3 deletions src/Microsoft.DotNet.Arcade.Sdk/tools/Settings.props
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,6 @@

<PropertyGroup>
<MSBuildAllProjects>$(MSBuildAllProjects);$(MSBuildThisFileFullPath)</MSBuildAllProjects>

<ImportNetSdkFromRepoToolset Condition="'$(ImportNetSdkFromRepoToolset)' == ''">true</ImportNetSdkFromRepoToolset>
</PropertyGroup>

<Import Project="BuildTasks.props" />
Expand All @@ -14,7 +12,13 @@
<Import Project="StrongName.props"/>
<Import Project="ProjectDefaults.props"/>
<Import Project="Tests.props" Condition="'$(DisableArcadeTestFramework)' != 'true'" />
<Import Project="Workarounds.props"/>

<Import Project="Compiler.props" Condition="'$(UsingToolMicrosoftNetCompilers)' == 'true'" />
<Import Project="Compiler.props" Condition="'$(UsingToolMicrosoftNetCompilers)' == 'true'" />
<Import Project="VisualStudio.props" Condition="'$(UsingToolVSSDK)' == 'true'"/>

<!--
Import NuGet props to WPF temp projects (workaround for https://github.com/dotnet/sourcelink/issues/91)
-->
<Import Project="$(_WpfTempProjectNuGetFilePathNoExt).props" Condition="'$(_WpfTempProjectNuGetFilePathNoExt)' != '' and Exists('$(_WpfTempProjectNuGetFilePathNoExt).props')"/>
</Project>
27 changes: 27 additions & 0 deletions src/Microsoft.DotNet.Arcade.Sdk/tools/Workarounds.props
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
<?xml version="1.0" encoding="utf-8"?>
<!-- Copyright (c) Microsoft. All Rights Reserved. Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information. -->
<Project>

<PropertyGroup>
<MSBuildAllProjects>$(MSBuildAllProjects);$(MSBuildThisFileFullPath)</MSBuildAllProjects>
</PropertyGroup>

<!--
Determine whether the project is WPF temp project.
Since .NET Framework 4.7.2 WPF temp project name ends with _wpftmp suffix and keeps the language specific extension (e.g. csproj).
-->
<PropertyGroup>
<IsWpfTempProject>false</IsWpfTempProject>
<IsWpfTempProject Condition="$(MSBuildProjectName.EndsWith('_wpftmp'))">true</IsWpfTempProject>
</PropertyGroup>

<!--
WPF temp-projects do not import .props and .targets files from NuGet packages.
(see https://github.com/dotnet/sourcelink/issues/91).

Property _TargetAssemblyProjectName is set by GenerateTemporaryTargetAssembly task.
-->
<PropertyGroup Condition="'$(IsWpfTempProject)' == 'true'">
<_WpfTempProjectNuGetFilePathNoExt>$(ArtifactsObjDir)$(_TargetAssemblyProjectName)\$(_TargetAssemblyProjectName)$(MSBuildProjectExtension).nuget.g</_WpfTempProjectNuGetFilePathNoExt>
</PropertyGroup>
</Project>
21 changes: 1 addition & 20 deletions src/Microsoft.DotNet.Arcade.Sdk/tools/Workarounds.targets
Original file line number Diff line number Diff line change
Expand Up @@ -27,32 +27,13 @@
</PropertyGroup>
</Target>

<PropertyGroup>
<IsWpfTempProject>false</IsWpfTempProject>
<IsWpfTempProject Condition="'$(MSBuildProjectExtension)' == '.tmp_proj' or $(MSBuildProjectName.EndsWith('_wpftmp'))">true</IsWpfTempProject>
</PropertyGroup>

<!--
Workaround for WPF temp projects.

XAML targets create a temp project with OutDir set, which makes the SDK create an empty directory for it,
WPF temp project sets OutDir, which makes the SDK create an empty directory for it,
polluting the output dir. Avoid creating these directories.
https://github.com/dotnet/sdk/issues/1367

WPF temp-projects do not import .props and .targets files from NuGet packages.
(see https://github.com/dotnet/sourcelink/issues/91).

This breaks SourceLink and Microsoft.NetFramework.ReferenceAssemblies.
-->
<PropertyGroup Condition="'$(IsWpfTempProject)' == 'true'">
<OutDir/>
<DeterministicSourcePaths>false</DeterministicSourcePaths>
</PropertyGroup>

<PropertyGroup Condition="'$(IsWpfTempProject)' == 'true' and '$(TargetFrameworkIdentifier)' == '.NETFramework' and '$(UsingToolNetFrameworkReferenceAssemblies)' == 'true'">
<TargetFrameworkRootPath>$(NuGetPackageRoot)microsoft.netframework.referenceassemblies.$(TargetFramework)\$(MicrosoftNetFrameworkReferenceAssembliesVersion)\build</TargetFrameworkRootPath>
<EnableFrameworkPathOverride>false</EnableFrameworkPathOverride>
<NoStdLib>true</NoStdLib>
</PropertyGroup>

<ItemGroup Condition="'$(IsWpfTempProject)' == 'true' and '$(TargetFrameworkIdentifier)' == '.NETFramework'">
Expand Down