Add test assets for testing and tiny bugfix
This commit is contained in:
parent
7edcf556d7
commit
8416085b3a
11 changed files with 283 additions and 3 deletions
|
@ -0,0 +1,32 @@
|
||||||
|
<?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" />
|
||||||
|
<PropertyGroup>
|
||||||
|
<OutputType>Exe</OutputType>
|
||||||
|
<TargetFrameworks>net451;netcoreapp1.0</TargetFrameworks>
|
||||||
|
</PropertyGroup>
|
||||||
|
<ItemGroup>
|
||||||
|
<Compile Include="**\*.cs" />
|
||||||
|
<EmbeddedResource Include="**\*.resx" />
|
||||||
|
<PackageReference Include="Microsoft.NET.Sdk">
|
||||||
|
<Version>1.0.0-alpha-20161104-2</Version>
|
||||||
|
<PrivateAssets>All</PrivateAssets>
|
||||||
|
</PackageReference>
|
||||||
|
</ItemGroup>
|
||||||
|
<ItemGroup Condition=" '$(TargetFramework)' == 'netcoreapp1.0' ">
|
||||||
|
<PackageReference Include="Microsoft.NETCore.App">
|
||||||
|
<Version>1.0.1</Version>
|
||||||
|
</PackageReference>
|
||||||
|
</ItemGroup>
|
||||||
|
<ItemGroup Condition="'$(TargetFramework)' == 'net451'">
|
||||||
|
<!-- This is intentionally empty - do not remove -->
|
||||||
|
</ItemGroup>
|
||||||
|
<PropertyGroup Condition=" '$(TargetFramework)' == 'netcoreapp1.0' ">
|
||||||
|
<DefineConstants>$(DefineConstants);NETCOREAPP1_0</DefineConstants>
|
||||||
|
</PropertyGroup>
|
||||||
|
<PropertyGroup Condition=" '$(TargetFramework)' == 'net451' ">
|
||||||
|
<DefineConstants>$(DefineConstants);NET451</DefineConstants>
|
||||||
|
</PropertyGroup>
|
||||||
|
|
||||||
|
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
|
||||||
|
</Project>
|
|
@ -0,0 +1,21 @@
|
||||||
|
using NSLib1;
|
||||||
|
using NSLib3;
|
||||||
|
|
||||||
|
namespace ConsoleApplication
|
||||||
|
{
|
||||||
|
public class Program
|
||||||
|
{
|
||||||
|
public static void Main(string[] args)
|
||||||
|
{
|
||||||
|
#if NETCOREAPP1_0
|
||||||
|
Lib1.HelloNCA();
|
||||||
|
Lib3.HelloNCA();
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#if NET451
|
||||||
|
Lib1.HelloNet451();
|
||||||
|
Lib3.HelloNet451();
|
||||||
|
#endif
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
|
@ -0,0 +1,24 @@
|
||||||
|
using System;
|
||||||
|
using NSLib2;
|
||||||
|
|
||||||
|
namespace NSLib1
|
||||||
|
{
|
||||||
|
public class Lib1
|
||||||
|
{
|
||||||
|
#if NETCOREAPP1_0
|
||||||
|
public static void HelloNCA()
|
||||||
|
{
|
||||||
|
Console.WriteLine("Hello World from Lib1! (netcoreapp)");
|
||||||
|
Lib2.HelloNCA();
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#if NET451
|
||||||
|
public static void HelloNet451()
|
||||||
|
{
|
||||||
|
Console.WriteLine("Hello World from Lib1! (net45)");
|
||||||
|
Lib2.HelloNet451();
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
}
|
||||||
|
}
|
|
@ -0,0 +1,29 @@
|
||||||
|
<?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" />
|
||||||
|
<PropertyGroup>
|
||||||
|
<OutputType>Library</OutputType>
|
||||||
|
<TargetFrameworks>net451;netcoreapp1.0</TargetFrameworks>
|
||||||
|
</PropertyGroup>
|
||||||
|
<ItemGroup>
|
||||||
|
<Compile Include="**\*.cs" />
|
||||||
|
<EmbeddedResource Include="**\*.resx" />
|
||||||
|
<PackageReference Include="Microsoft.NET.Sdk">
|
||||||
|
<Version>1.0.0-alpha-20161104-2</Version>
|
||||||
|
<PrivateAssets>All</PrivateAssets>
|
||||||
|
</PackageReference>
|
||||||
|
</ItemGroup>
|
||||||
|
<ItemGroup Condition=" '$(TargetFramework)' == 'netcoreapp1.0' ">
|
||||||
|
<PackageReference Include="Microsoft.NETCore.App">
|
||||||
|
<Version>1.0.1</Version>
|
||||||
|
</PackageReference>
|
||||||
|
</ItemGroup>
|
||||||
|
<PropertyGroup Condition=" '$(TargetFramework)' == 'netcoreapp1.0' ">
|
||||||
|
<DefineConstants>$(DefineConstants);NETCOREAPP1_0</DefineConstants>
|
||||||
|
</PropertyGroup>
|
||||||
|
<PropertyGroup Condition=" '$(TargetFramework)' == 'net451' ">
|
||||||
|
<DefineConstants>$(DefineConstants);NET451</DefineConstants>
|
||||||
|
</PropertyGroup>
|
||||||
|
|
||||||
|
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
|
||||||
|
</Project>
|
|
@ -0,0 +1,24 @@
|
||||||
|
using System;
|
||||||
|
using NSLib4;
|
||||||
|
|
||||||
|
namespace NSLib2
|
||||||
|
{
|
||||||
|
public class Lib2
|
||||||
|
{
|
||||||
|
#if NETCOREAPP1_0
|
||||||
|
public static void HelloNCA()
|
||||||
|
{
|
||||||
|
Console.WriteLine("Hello World from Lib2! (netcoreapp)");
|
||||||
|
Lib4.HelloNCA();
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#if NET451
|
||||||
|
public static void HelloNet451()
|
||||||
|
{
|
||||||
|
Console.WriteLine("Hello World from Lib2! (net45)");
|
||||||
|
Lib4.HelloNet451();
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
}
|
||||||
|
}
|
|
@ -0,0 +1,36 @@
|
||||||
|
<?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" />
|
||||||
|
<PropertyGroup>
|
||||||
|
<OutputType>Library</OutputType>
|
||||||
|
<TargetFrameworks>net451;netcoreapp1.0</TargetFrameworks>
|
||||||
|
</PropertyGroup>
|
||||||
|
<ItemGroup>
|
||||||
|
<Compile Include="**\*.cs" />
|
||||||
|
<EmbeddedResource Include="**\*.resx" />
|
||||||
|
<PackageReference Include="Microsoft.NET.Sdk">
|
||||||
|
<Version>1.0.0-alpha-20161104-2</Version>
|
||||||
|
<PrivateAssets>All</PrivateAssets>
|
||||||
|
</PackageReference>
|
||||||
|
</ItemGroup>
|
||||||
|
<ItemGroup Condition=" '$(TargetFramework)' == 'netcoreapp1.0' ">
|
||||||
|
<PackageReference Include="Microsoft.NETCore.App">
|
||||||
|
<Version>1.0.1</Version>
|
||||||
|
</PackageReference>
|
||||||
|
</ItemGroup>
|
||||||
|
<ItemGroup>
|
||||||
|
<!-- Spaces in the condition are intentional -->
|
||||||
|
<ProjectReference Condition=" '$(TargetFramework)' == 'netcoreapp1.0' " Include="../Lib4/Lib4.csproj" />
|
||||||
|
</ItemGroup>
|
||||||
|
<ItemGroup>
|
||||||
|
<ProjectReference Condition="'$(TargetFramework)' == 'net451'" Include="../Lib4/Lib4.csproj" />
|
||||||
|
</ItemGroup>
|
||||||
|
<PropertyGroup Condition=" '$(TargetFramework)' == 'netcoreapp1.0' ">
|
||||||
|
<DefineConstants>$(DefineConstants);NETCOREAPP1_0</DefineConstants>
|
||||||
|
</PropertyGroup>
|
||||||
|
<PropertyGroup Condition=" '$(TargetFramework)' == 'net451' ">
|
||||||
|
<DefineConstants>$(DefineConstants);NET451</DefineConstants>
|
||||||
|
</PropertyGroup>
|
||||||
|
|
||||||
|
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
|
||||||
|
</Project>
|
|
@ -0,0 +1,21 @@
|
||||||
|
using System;
|
||||||
|
|
||||||
|
namespace NSLib3
|
||||||
|
{
|
||||||
|
public class Lib3
|
||||||
|
{
|
||||||
|
#if NETCOREAPP1_0
|
||||||
|
public static void HelloNCA()
|
||||||
|
{
|
||||||
|
Console.WriteLine("Hello World from Lib3! (netcoreapp)");
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#if NET451
|
||||||
|
public static void HelloNet451()
|
||||||
|
{
|
||||||
|
Console.WriteLine("Hello World from Lib3! (net45)");
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
}
|
||||||
|
}
|
|
@ -0,0 +1,29 @@
|
||||||
|
<?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" />
|
||||||
|
<PropertyGroup>
|
||||||
|
<OutputType>Library</OutputType>
|
||||||
|
<TargetFrameworks>net451;netcoreapp1.0</TargetFrameworks>
|
||||||
|
</PropertyGroup>
|
||||||
|
<ItemGroup>
|
||||||
|
<Compile Include="**\*.cs" />
|
||||||
|
<EmbeddedResource Include="**\*.resx" />
|
||||||
|
<PackageReference Include="Microsoft.NET.Sdk">
|
||||||
|
<Version>1.0.0-alpha-20161104-2</Version>
|
||||||
|
<PrivateAssets>All</PrivateAssets>
|
||||||
|
</PackageReference>
|
||||||
|
</ItemGroup>
|
||||||
|
<ItemGroup Condition=" '$(TargetFramework)' == 'netcoreapp1.0' ">
|
||||||
|
<PackageReference Include="Microsoft.NETCore.App">
|
||||||
|
<Version>1.0.1</Version>
|
||||||
|
</PackageReference>
|
||||||
|
</ItemGroup>
|
||||||
|
<PropertyGroup Condition=" '$(TargetFramework)' == 'netcoreapp1.0' ">
|
||||||
|
<DefineConstants>$(DefineConstants);NETCOREAPP1_0</DefineConstants>
|
||||||
|
</PropertyGroup>
|
||||||
|
<PropertyGroup Condition=" '$(TargetFramework)' == 'net451' ">
|
||||||
|
<DefineConstants>$(DefineConstants);NET451</DefineConstants>
|
||||||
|
</PropertyGroup>
|
||||||
|
|
||||||
|
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
|
||||||
|
</Project>
|
|
@ -0,0 +1,21 @@
|
||||||
|
using System;
|
||||||
|
|
||||||
|
namespace NSLib4
|
||||||
|
{
|
||||||
|
public class Lib4
|
||||||
|
{
|
||||||
|
#if NETCOREAPP1_0
|
||||||
|
public static void HelloNCA()
|
||||||
|
{
|
||||||
|
Console.WriteLine("Hello World from Lib4! (netcoreapp)");
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#if NET451
|
||||||
|
public static void HelloNet451()
|
||||||
|
{
|
||||||
|
Console.WriteLine("Hello World from Lib4! (net45)");
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
}
|
||||||
|
}
|
|
@ -0,0 +1,32 @@
|
||||||
|
<?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" />
|
||||||
|
<PropertyGroup>
|
||||||
|
<OutputType>Library</OutputType>
|
||||||
|
<TargetFrameworks>net451;netcoreapp1.0</TargetFrameworks>
|
||||||
|
</PropertyGroup>
|
||||||
|
<ItemGroup>
|
||||||
|
<Compile Include="**\*.cs" />
|
||||||
|
<EmbeddedResource Include="**\*.resx" />
|
||||||
|
<PackageReference Include="Microsoft.NET.Sdk">
|
||||||
|
<Version>1.0.0-alpha-20161104-2</Version>
|
||||||
|
<PrivateAssets>All</PrivateAssets>
|
||||||
|
</PackageReference>
|
||||||
|
</ItemGroup>
|
||||||
|
<ItemGroup Condition=" '$(TargetFramework)' == 'netcoreapp1.0' ">
|
||||||
|
<PackageReference Include="Microsoft.NETCore.App">
|
||||||
|
<Version>1.0.1</Version>
|
||||||
|
</PackageReference>
|
||||||
|
</ItemGroup>
|
||||||
|
<ItemGroup Condition="'$(TargetFramework)' == 'net451'">
|
||||||
|
<!-- Existing but empty item group for net451 - do not remove -->
|
||||||
|
</ItemGroup>
|
||||||
|
<PropertyGroup Condition=" '$(TargetFramework)' == 'netcoreapp1.0' ">
|
||||||
|
<DefineConstants>$(DefineConstants);NETCOREAPP1_0</DefineConstants>
|
||||||
|
</PropertyGroup>
|
||||||
|
<PropertyGroup Condition=" '$(TargetFramework)' == 'net451' ">
|
||||||
|
<DefineConstants>$(DefineConstants);NET451</DefineConstants>
|
||||||
|
</PropertyGroup>
|
||||||
|
|
||||||
|
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
|
||||||
|
</Project>
|
|
@ -129,12 +129,18 @@ namespace Microsoft.DotNet.Tools.Add.ProjectToProjectReference
|
||||||
|
|
||||||
public static string GetFrameworkConditionString(string framework)
|
public static string GetFrameworkConditionString(string framework)
|
||||||
{
|
{
|
||||||
|
if (string.IsNullOrEmpty(framework))
|
||||||
|
{
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
return $" '$(TargetFramework)' == '{framework}' ";
|
return $" '$(TargetFramework)' == '{framework}' ";
|
||||||
}
|
}
|
||||||
|
|
||||||
public static Func<T, bool> FrameworkPred<T>(string framework) where T : ProjectElement
|
public static Func<T, bool> FrameworkPred<T>(string framework) where T : ProjectElement
|
||||||
{
|
{
|
||||||
if (string.IsNullOrEmpty(framework))
|
string conditionStr = GetFrameworkConditionString(framework);
|
||||||
|
if (conditionStr == null)
|
||||||
{
|
{
|
||||||
return (ig) => {
|
return (ig) => {
|
||||||
var condChain = ig.ConditionChain();
|
var condChain = ig.ConditionChain();
|
||||||
|
@ -142,7 +148,7 @@ namespace Microsoft.DotNet.Tools.Add.ProjectToProjectReference
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
string conditionStr = GetFrameworkConditionString(framework).Trim();
|
conditionStr = conditionStr.Trim();
|
||||||
return (ig) => {
|
return (ig) => {
|
||||||
var condChain = ig.ConditionChain();
|
var condChain = ig.ConditionChain();
|
||||||
return condChain.Count == 1 && condChain.First().Trim() == conditionStr;
|
return condChain.Count == 1 && condChain.First().Trim() == conditionStr;
|
||||||
|
@ -193,7 +199,12 @@ namespace Microsoft.DotNet.Tools.Add.ProjectToProjectReference
|
||||||
}
|
}
|
||||||
|
|
||||||
ProjectItemGroupElement ret = root.CreateItemGroupElement();
|
ProjectItemGroupElement ret = root.CreateItemGroupElement();
|
||||||
ret.Condition = GetFrameworkConditionString(framework);
|
string condStr = GetFrameworkConditionString(framework);
|
||||||
|
if (condStr != null)
|
||||||
|
{
|
||||||
|
ret.Condition = condStr;
|
||||||
|
}
|
||||||
|
|
||||||
root.AppendChild(ret);
|
root.AppendChild(ret);
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue