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

Skip nearest target framework resolution if TargetFramework is specified and ReferringTargetFramework is empty #418

Merged
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.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
<Project ToolsVersion="15.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003" DefaultTargets="Build">

<PropertyGroup>
<SkipCopyBuildProduct>true</SkipCopyBuildProduct>
<TargetRuntime>None</TargetRuntime>
<OutputType>FabricApplication</OutputType>
</PropertyGroup>

<ItemGroup>
<ProjectReference Include="../HelloWorld/HelloWorld.csproj" />
</ItemGroup>


<Import Project="$(MSBuildToolsPath)\Microsoft.Common.targets" />

<Target Name="CreateManifestResourceNames" />
<Target Name="CoreCompile" />

</Project>
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
<Project ToolsVersion="15.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<Import Project="$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props" />

<PropertyGroup>
<OutputType>Exe</OutputType>
<TargetFramework>netcoreapp1.0</TargetFramework>
</PropertyGroup>

<ItemGroup>
<Compile Include="**\*.cs" />
<EmbeddedResource Include="**\*.resx" />
</ItemGroup>

<ItemGroup>
<PackageReference Include="Microsoft.NETCore.App">
<Version>1.0.1</Version>
</PackageReference>
<PackageReference Include="Microsoft.NET.Sdk">
<Version>0.0</Version>
<PrivateAssets>All</PrivateAssets>
</PackageReference>
</ItemGroup>

<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
</Project>
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
using System;

namespace ConsoleApplication
{
public class Program
{
public static void Main(string[] args)
{
Console.WriteLine("Hello World!");
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -59,13 +59,18 @@ Copyright (c) .NET Foundation. All rights reserved.
<Target Name="GetTargetFrameworkProperties" Returns="TargetFramework=$(NearestTargetFramework)">

<PropertyGroup>
<!-- If a ReferringTargetFramework was not specified, and we only have one TargetFramework, then don't try to check compatibility -->
<_SkipNearestTargetFrameworkResolution Condition="'$(TargetFramework)' != '' and '$(ReferringTargetFramework)' == ''">true</_SkipNearestTargetFrameworkResolution>
<NearestTargetFramework Condition="'$(_SkipNearestTargetFrameworkResolution)' == 'true'">$(TargetFramework)</NearestTargetFramework>

<_PossibleTargetFrameworks Condition="'$(TargetFramework)' != ''">$(TargetFramework)</_PossibleTargetFrameworks>
<_PossibleTargetFrameworks Condition="'$(TargetFramework)' == ''">$(TargetFrameworks)</_PossibleTargetFrameworks>
</PropertyGroup>

<GetNearestTargetFramework ReferringTargetFramework="$(ReferringTargetFramework)"
PossibleTargetFrameworks="$(_PossibleTargetFrameworks)"
ProjectFilePath="$(MSBuildProjectFullPath)">
ProjectFilePath="$(MSBuildProjectFullPath)"
Condition="'$(_SkipNearestTargetFrameworkResolution)' != 'true'">
<Output PropertyName="NearestTargetFramework" TaskParameter="NearestTargetFramework" />
</GetNearestTargetFramework>
</Target>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -94,5 +94,23 @@ public void It_publishes_self_contained_apps_to_the_publish_folder_and_the_app_s
.And
.HaveStdOutContaining("Hello World!");
}

[Fact]
public void A_deployment_project_can_reference_the_hello_world_project()
{
var rid = RuntimeEnvironment.GetRuntimeIdentifier();

var helloWorldAsset = _testAssetsManager
.CopyTestAsset("DeployProjectReferencingSdkProject")
.WithSource()
.Restore(relativePath: "HelloWorld", args: $"/p:RuntimeIdentifiers={rid}");

var buildCommand = new BuildCommand(Stage0MSBuild, helloWorldAsset.TestRoot, @"DeployProj\Deploy.proj");

buildCommand
.Execute()
.Should()
.Pass();
}
}
}