binding redirects tests: Simplify and get ready for enabling (#4692)
* binding redirects tests: Simplify and get ready for enabling * fix targets broken during cleanup * fix non-windows build * apply pr feedback: remove some not needed code * remigrate BindingRedirects samples, add x64 to bind redir proj
This commit is contained in:
parent
6d57ca7e14
commit
9212605e89
22 changed files with 363 additions and 387 deletions
|
@ -0,0 +1,53 @@
|
|||
<Project ToolsVersion="15.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
|
||||
<Import Project="$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props" />
|
||||
|
||||
<PropertyGroup>
|
||||
<TargetFramework>net46</TargetFramework>
|
||||
<AssemblyName>AppWithRedirectsAndConfig</AssemblyName>
|
||||
<OutputType>Exe</OutputType>
|
||||
<RuntimeIdentifiers>win7-x64;win7-x86</RuntimeIdentifiers>
|
||||
</PropertyGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<Compile Include="**\*.cs" Exclude="bin\**;obj\**;**\*.xproj;packages\**" />
|
||||
<Compile Include="..\src\*.cs" Exclude="bin\**;obj\**;**\*.xproj;packages\**" />
|
||||
<EmbeddedResource Include="**\*.resx" />
|
||||
<EmbeddedResource Include="compiler\resources\**\*" />
|
||||
</ItemGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<PackageReference Include="Microsoft.NET.Sdk">
|
||||
<Version>1.0.0-alpha-20161104-2</Version>
|
||||
<PrivateAssets>All</PrivateAssets>
|
||||
</PackageReference>
|
||||
<PackageReference Include="Newtonsoft.Json">
|
||||
<Version>8.0.3</Version>
|
||||
</PackageReference>
|
||||
<PackageReference Include="Microsoft.AspNet.Mvc">
|
||||
<Version>3.0.50813.1</Version>
|
||||
</PackageReference>
|
||||
<PackageReference Include="Unity.Mvc">
|
||||
<Version>3.0.1304</Version>
|
||||
</PackageReference>
|
||||
<PackageReference Include="dotnet-desktop-binding-redirects">
|
||||
<Version>1.0.0-*</Version>
|
||||
</PackageReference>
|
||||
</ItemGroup>
|
||||
|
||||
<ItemGroup Condition=" '$(TargetFramework)' == 'net46' ">
|
||||
<Reference Include="System" />
|
||||
<Reference Include="Microsoft.CSharp" />
|
||||
</ItemGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<DotNetCliToolReference Include="dotnet-dependency-tool-invoker">
|
||||
<Version>1.0.0-*</Version>
|
||||
</DotNetCliToolReference>
|
||||
</ItemGroup>
|
||||
|
||||
<PropertyGroup Condition=" '$(Configuration)' == 'Release' ">
|
||||
<DefineConstants>$(DefineConstants);RELEASE</DefineConstants>
|
||||
</PropertyGroup>
|
||||
|
||||
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
|
||||
</Project>
|
|
@ -1,29 +0,0 @@
|
|||
{
|
||||
"version": "1.0.0-*",
|
||||
"buildOptions": {
|
||||
"emitEntryPoint": true,
|
||||
"compile": {
|
||||
"include": [
|
||||
"../src/*.cs"
|
||||
]
|
||||
}
|
||||
},
|
||||
"dependencies": {
|
||||
"Newtonsoft.Json": "8.0.3",
|
||||
"Microsoft.AspNet.Mvc": "3.0.50813.1",
|
||||
"Unity.Mvc": "3.0.1304",
|
||||
"dotnet-desktop-binding-redirects": "1.0.0-*"
|
||||
},
|
||||
"frameworks": {
|
||||
"net46": {}
|
||||
},
|
||||
"tools": {
|
||||
"dotnet-dependency-tool-invoker": {
|
||||
"version": "1.0.0-*",
|
||||
"imports": [
|
||||
"dnxcore50",
|
||||
"portable-net45+win8"
|
||||
]
|
||||
}
|
||||
}
|
||||
}
|
|
@ -0,0 +1,53 @@
|
|||
<Project ToolsVersion="15.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
|
||||
<Import Project="$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props" />
|
||||
|
||||
<PropertyGroup>
|
||||
<TargetFramework>net46</TargetFramework>
|
||||
<AssemblyName>AppWithRedirectsNoConfig</AssemblyName>
|
||||
<OutputType>Exe</OutputType>
|
||||
<RuntimeIdentifiers>win7-x64;win7-x86</RuntimeIdentifiers>
|
||||
</PropertyGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<Compile Include="**\*.cs" Exclude="bin\**;obj\**;**\*.xproj;packages\**" />
|
||||
<Compile Include="..\src\*.cs" Exclude="bin\**;obj\**;**\*.xproj;packages\**" />
|
||||
<EmbeddedResource Include="**\*.resx" />
|
||||
<EmbeddedResource Include="compiler\resources\**\*" />
|
||||
</ItemGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<PackageReference Include="Microsoft.NET.Sdk">
|
||||
<Version>1.0.0-alpha-20161104-2</Version>
|
||||
<PrivateAssets>All</PrivateAssets>
|
||||
</PackageReference>
|
||||
<PackageReference Include="Newtonsoft.Json">
|
||||
<Version>8.0.3</Version>
|
||||
</PackageReference>
|
||||
<PackageReference Include="Microsoft.AspNet.Mvc">
|
||||
<Version>3.0.50813.1</Version>
|
||||
</PackageReference>
|
||||
<PackageReference Include="Unity.Mvc">
|
||||
<Version>3.0.1304</Version>
|
||||
</PackageReference>
|
||||
<PackageReference Include="dotnet-desktop-binding-redirects">
|
||||
<Version>1.0.0-*</Version>
|
||||
</PackageReference>
|
||||
</ItemGroup>
|
||||
|
||||
<ItemGroup Condition=" '$(TargetFramework)' == 'net46' ">
|
||||
<Reference Include="System" />
|
||||
<Reference Include="Microsoft.CSharp" />
|
||||
</ItemGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<DotNetCliToolReference Include="dotnet-dependency-tool-invoker">
|
||||
<Version>1.0.0-*</Version>
|
||||
</DotNetCliToolReference>
|
||||
</ItemGroup>
|
||||
|
||||
<PropertyGroup Condition=" '$(Configuration)' == 'Release' ">
|
||||
<DefineConstants>$(DefineConstants);RELEASE</DefineConstants>
|
||||
</PropertyGroup>
|
||||
|
||||
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
|
||||
</Project>
|
|
@ -1,29 +0,0 @@
|
|||
{
|
||||
"version": "1.0.0-*",
|
||||
"buildOptions": {
|
||||
"emitEntryPoint": true,
|
||||
"compile": {
|
||||
"include": [
|
||||
"../src/*.cs"
|
||||
]
|
||||
}
|
||||
},
|
||||
"dependencies": {
|
||||
"Newtonsoft.Json": "8.0.3",
|
||||
"Microsoft.AspNet.Mvc": "3.0.50813.1",
|
||||
"Unity.Mvc": "3.0.1304",
|
||||
"dotnet-desktop-binding-redirects": "1.0.0-*"
|
||||
},
|
||||
"frameworks": {
|
||||
"net46": {}
|
||||
},
|
||||
"tools": {
|
||||
"dotnet-dependency-tool-invoker": {
|
||||
"version": "1.0.0-*",
|
||||
"imports": [
|
||||
"dnxcore50",
|
||||
"portable-net45+win8"
|
||||
]
|
||||
}
|
||||
}
|
||||
}
|
|
@ -0,0 +1,6 @@
|
|||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<configuration>
|
||||
<packageSources>
|
||||
<add key="test-packages" value="../../../artifacts/testpackages" />
|
||||
</packageSources>
|
||||
</configuration>
|
|
@ -0,0 +1,43 @@
|
|||
<Project ToolsVersion="15.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
|
||||
<Import Project="$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props" />
|
||||
|
||||
<PropertyGroup>
|
||||
<VersionPrefix>1.0.0-rc</VersionPrefix>
|
||||
<TargetFramework>net451</TargetFramework>
|
||||
<AssemblyName>dotnet-desktop-binding-redirects</AssemblyName>
|
||||
<OutputType>Exe</OutputType>
|
||||
<RuntimeIdentifiers>win7-x86;win7-x64</RuntimeIdentifiers>
|
||||
<AutoGenerateBindingRedirects>true</AutoGenerateBindingRedirects>
|
||||
</PropertyGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<Compile Include="**\*.cs" />
|
||||
<EmbeddedResource Include="**\*.resx" />
|
||||
<EmbeddedResource Include="compiler\resources\**\*" />
|
||||
</ItemGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<PackageReference Include="Microsoft.NET.Sdk">
|
||||
<Version>1.0.0-alpha-20161104-2</Version>
|
||||
<PrivateAssets>All</PrivateAssets>
|
||||
</PackageReference>
|
||||
<PackageReference Include="Newtonsoft.Json">
|
||||
<Version>5.0.0</Version>
|
||||
</PackageReference>
|
||||
<PackageReference Include="NuGet.Protocol.Core.v3">
|
||||
<Version>3.3.0</Version>
|
||||
</PackageReference>
|
||||
</ItemGroup>
|
||||
|
||||
<ItemGroup Condition=" '$(TargetFramework)' == 'net451' ">
|
||||
<Reference Include="System.Configuration" />
|
||||
<Reference Include="System" />
|
||||
<Reference Include="Microsoft.CSharp" />
|
||||
</ItemGroup>
|
||||
|
||||
<PropertyGroup Condition=" '$(Configuration)' == 'Release' ">
|
||||
<DefineConstants>$(DefineConstants);RELEASE</DefineConstants>
|
||||
</PropertyGroup>
|
||||
|
||||
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
|
||||
</Project>
|
|
@ -1,19 +0,0 @@
|
|||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<Project ToolsVersion="14.0" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
|
||||
<PropertyGroup>
|
||||
<VisualStudioVersion Condition="'$(VisualStudioVersion)' == ''">14.0</VisualStudioVersion>
|
||||
<VSToolsPath Condition="'$(VSToolsPath)' == ''">$(MSBuildExtensionsPath32)\Microsoft\VisualStudio\v$(VisualStudioVersion)</VSToolsPath>
|
||||
</PropertyGroup>
|
||||
<Import Project="$(VSToolsPath)\DNX\Microsoft.DNX.Props" Condition="'$(VSToolsPath)' != ''" />
|
||||
<PropertyGroup Label="Globals">
|
||||
<ProjectGuid>281f1cdb-8627-47c7-9bb1-cde8d30d93d1</ProjectGuid>
|
||||
<RootNamespace>dotnet-desktop-binding-redirects</RootNamespace>
|
||||
<BaseIntermediateOutputPath Condition="'$(BaseIntermediateOutputPath)'=='' ">..\artifacts\obj\$(MSBuildProjectName)</BaseIntermediateOutputPath>
|
||||
<OutputPath Condition="'$(OutputPath)'=='' ">..\artifacts\bin\$(MSBuildProjectName)\</OutputPath>
|
||||
</PropertyGroup>
|
||||
|
||||
<PropertyGroup>
|
||||
<SchemaVersion>2.0</SchemaVersion>
|
||||
</PropertyGroup>
|
||||
<Import Project="$(VSToolsPath)\DNX\Microsoft.DNX.targets" Condition="'$(VSToolsPath)' != ''" />
|
||||
</Project>
|
|
@ -1,17 +0,0 @@
|
|||
{
|
||||
"version": "1.0.0-rc-*",
|
||||
"buildOptions": {
|
||||
"emitEntryPoint": true
|
||||
},
|
||||
"dependencies": {
|
||||
"Newtonsoft.Json": "5.0.0",
|
||||
"NuGet.Protocol.Core.v3": "3.3.0"
|
||||
},
|
||||
"frameworks": {
|
||||
"net451": {
|
||||
"frameworkAssemblies": {
|
||||
"System.Configuration": ""
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
|
@ -172,7 +172,8 @@
|
|||
<Message Text="Skipping projects with .noautobuild files:" />
|
||||
<Message Text="%(NoAutoBuildDesktopTestAssetProjects.FullPath)" />
|
||||
|
||||
<DotNetBuild Configuration="$(Configuration)"
|
||||
<DotNetBuild Condition="'@(BuildableDesktopTestAssetProjects)' != ''"
|
||||
Configuration="$(Configuration)"
|
||||
Framework="net46"
|
||||
ProjectPath="%(BuildableDesktopTestAssetProjects.FullPath)"
|
||||
ToolPath="$(Stage0PjDirectory)" />
|
||||
|
@ -197,45 +198,81 @@
|
|||
</Target>
|
||||
|
||||
<Target Name="CreateTestAssetPackageNuPkgs"
|
||||
DependsOnTargets="BuildTestAssetPackageProjects;
|
||||
DependsOnTargets="CreateTestAssetPackageNuPkgsFromProjectJsons;
|
||||
CreateTestAssetPackageNuPkgsFromMsbuildProjects;">
|
||||
</Target>
|
||||
|
||||
<Target Name="CreateTestAssetPackageNuPkgsFromProjectJsons"
|
||||
DependsOnTargets="BuildTestAssetPackageJsonProjects;
|
||||
SetupTestPackageProjectData;"
|
||||
Inputs="%(TestPackageProject.PackInputs)"
|
||||
Outputs="%(TestPackageProject.PackOutputs)">
|
||||
|
||||
<DotNetPackPj BuildBasePath="$(TestPackagesBuildDir)"
|
||||
<DotNetPackPj Condition="'%(TestPackageProject.IsMsbuild)' != 'True'"
|
||||
BuildBasePath="$(TestPackagesBuildDir)"
|
||||
NoBuild="True"
|
||||
Output="$(TestPackagesDir)"
|
||||
ProjectPath="%(TestPackageProject.FullPath)"
|
||||
ToolPath="$(Stage0PjDirectory)"
|
||||
VersionSuffix="%(TestPackageProject.VersionSuffix)" />
|
||||
</Target>
|
||||
|
||||
<Target Name="CreateTestAssetPackageNuPkgsFromMsbuildProjects"
|
||||
DependsOnTargets="RestoreTestAssetPackageMsbuildProjects;
|
||||
SetupTestPackageProjectData;">
|
||||
<DotNetPack Condition="'@(TestPackageCsProj)' != ''"
|
||||
Output="$(TestPackagesDir)"
|
||||
Runtime="%(TestPackageCsProj.Runtime)"
|
||||
ToolPath="$(Stage2Directory)"
|
||||
VersionSuffix="%(TestPackageCsProj.VersionSuffix)"
|
||||
WorkingDirectory="%(TestPackageCsProj.WorkingDirectory)" />
|
||||
</Target>
|
||||
|
||||
<Target Name="BuildTestAssetPackageProjects"
|
||||
DependsOnTargets="RestoreTestAssetPackageProjects;
|
||||
<Target Name="BuildTestAssetPackageJsonProjects"
|
||||
DependsOnTargets="RestoreTestAssetPackageJsonProjects;
|
||||
SetupTestPackageProjectData;"
|
||||
Inputs="%(TestPackageProject.BuildInputs)"
|
||||
Outputs="%(TestPackageProject.BuildOutputs)">
|
||||
|
||||
<DotNetBuildPj BuildBasePath="$(TestPackagesBuildDir)"
|
||||
<DotNetBuildPj Condition="'%(TestPackageProject.IsMsbuild)' != 'True'"
|
||||
BuildBasePath="$(TestPackagesBuildDir)"
|
||||
Framework="%(TestPackageProject.Framework)"
|
||||
ProjectPath="%(TestPackageProject.FullPath)"
|
||||
ToolPath="$(Stage0PjDirectory)" />
|
||||
</Target>
|
||||
|
||||
<Target Name="RestoreTestAssetPackageProjects"
|
||||
<Target Name="PrepareTestAssetPackageMsbuildProjects">
|
||||
<ItemGroup>
|
||||
<TestPackageCsProj Condition="'%(TestPackageProject.IsMsbuild)' == 'True'"
|
||||
Include="@(TestPackageProject)">
|
||||
<Framework>%(TestPackageProject.Framework)</Framework>
|
||||
<Runtime>%(TestPackageProject.Runtime)</Runtime>
|
||||
<VersionSuffix>rc-%(TestPackageProject.VersionSuffix)</VersionSuffix>
|
||||
<WorkingDirectory>%(TestPackageProject.FullPath)</WorkingDirectory>
|
||||
</TestPackageCsProj>
|
||||
</ItemGroup>
|
||||
</Target>
|
||||
|
||||
<Target Name="RestoreTestAssetPackageJsonProjects"
|
||||
DependsOnTargets="PrepareTests;
|
||||
SetupRestoreTestAssetPackageProjectsInputs;"
|
||||
Inputs="@(RestoreTestAssetPackageProjectsInputs)"
|
||||
Outputs="@(RestoreTestAssetPackageProjectsInputs->'%(RelativeDir)/project.lock.json')">
|
||||
|
||||
<DotNetRestorePJ ToolPath="$(Stage0PjDirectory)"
|
||||
WorkingDirectory="$(RepoRoot)/TestAssets/TestPackages/" />
|
||||
</Target>
|
||||
|
||||
<Target Name="RestoreTestAssetPackageMsbuildProjects"
|
||||
DependsOnTargets="PrepareTestAssetPackageMsbuildProjects">
|
||||
<DotNetRestore Condition="'@(TestPackageCsProj)' != ''"
|
||||
ToolPath="$(Stage2Directory)"
|
||||
Runtime="%(TestPackageCsProj.Runtime)"
|
||||
WorkingDirectory="%(TestPackageCsProj.WorkingDirectory)" />
|
||||
</Target>
|
||||
|
||||
<Target Name="SetupRestoreTestAssetPackageProjectsInputs"
|
||||
DependsOnTargets="Init;">
|
||||
<ItemGroup>
|
||||
<RestoreTestAssetPackageProjectsInputs Include="$(RepoRoot)/TestAssets/TestPackages/**/project.json" />
|
||||
</ItemGroup>
|
||||
</Target>
|
||||
</Project>
|
||||
</Project>
|
||||
|
|
|
@ -109,11 +109,13 @@
|
|||
Condition=" '$(IsDesktopAvailable)' == 'True' ">
|
||||
<Name>dotnet-desktop-binding-redirects</Name>
|
||||
<IsTool>True</IsTool>
|
||||
<IsMsbuild>True</IsMsbuild>
|
||||
<IsApplicable>$(DesktopAvailable)</IsApplicable>
|
||||
<VersionPrefix>1.0.0-rc-</VersionPrefix>
|
||||
<VersionSuffix>$(TestPackageBuildVersionSuffix)</VersionSuffix>
|
||||
<Clean>True</Clean>
|
||||
<Frameworks>net451</Frameworks>
|
||||
<Runtime>win7-x86</Runtime>
|
||||
</BaseTestPackageProject>
|
||||
<BaseTestPackageProject Include="TestAssets/TestPackages/dotnet-hello/v1/dotnet-hello">
|
||||
<Name>dotnet-hello</Name>
|
||||
|
|
|
@ -85,9 +85,6 @@
|
|||
<BuildOutput>$(RepoRoot)%(TestProjects.RelativeDir)bin/$(Configuration)/%(TestProjects.Framework)/%(TestProjects.OutputName).dll</BuildOutput>
|
||||
</TestProjects>
|
||||
|
||||
<TestProjects Condition=" '%(RelativeDir)' == 'test\binding-redirects.Tests\' ">
|
||||
<Framework>net46</Framework>
|
||||
</TestProjects>
|
||||
<TestProjects Condition=" '%(RelativeDir)' == 'test\Installer\Microsoft.DotNet.Cli.Msi.Tests\' ">
|
||||
<Framework>net46</Framework>
|
||||
</TestProjects>
|
||||
|
|
|
@ -12,7 +12,7 @@ namespace Microsoft.DotNet.Cli.Build
|
|||
|
||||
protected override string Args
|
||||
{
|
||||
get { return $"{GetProjectPath()} {GetConfiguration()} {GetFramework()}"; }
|
||||
get { return $"{GetProjectPath()} {GetConfiguration()} {GetFramework()} {GetRuntime()} {GetOutputPath()}"; }
|
||||
}
|
||||
|
||||
public string BuildBasePath { get; set; }
|
||||
|
@ -20,9 +20,23 @@ namespace Microsoft.DotNet.Cli.Build
|
|||
public string Configuration { get; set; }
|
||||
|
||||
public string Framework { get; set; }
|
||||
|
||||
public string Runtime { get; set; }
|
||||
|
||||
public string ProjectPath { get; set; }
|
||||
|
||||
public string OutputPath { get; set; }
|
||||
|
||||
private string GetOutputPath()
|
||||
{
|
||||
if (!string.IsNullOrEmpty(OutputPath))
|
||||
{
|
||||
return $"--output {OutputPath}";
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
private string GetConfiguration()
|
||||
{
|
||||
if (!string.IsNullOrEmpty(Configuration))
|
||||
|
@ -42,6 +56,16 @@ namespace Microsoft.DotNet.Cli.Build
|
|||
|
||||
return null;
|
||||
}
|
||||
|
||||
private string GetRuntime()
|
||||
{
|
||||
if (!string.IsNullOrEmpty(Runtime))
|
||||
{
|
||||
return $"--runtime {Runtime}";
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
private string GetProjectPath()
|
||||
{
|
||||
|
|
|
@ -12,7 +12,7 @@ namespace Microsoft.DotNet.Cli.Build
|
|||
|
||||
protected override string Args
|
||||
{
|
||||
get { return $"{GetProjectPath()} {GetConfiguration()} {GetNoBuild()} {GetOutput()} {GetVersionSuffix()}"; }
|
||||
get { return $"{GetProjectPath()} {GetConfiguration()} {GetNoBuild()} {GetOutput()} {GetVersionSuffix()} {GetRuntime()}"; }
|
||||
}
|
||||
|
||||
public string Configuration { get; set; }
|
||||
|
@ -24,6 +24,8 @@ namespace Microsoft.DotNet.Cli.Build
|
|||
public string ProjectPath { get; set; }
|
||||
|
||||
public string VersionSuffix { get; set; }
|
||||
|
||||
public string Runtime { get; set; }
|
||||
|
||||
private string GetConfiguration()
|
||||
{
|
||||
|
@ -74,5 +76,15 @@ namespace Microsoft.DotNet.Cli.Build
|
|||
|
||||
return null;
|
||||
}
|
||||
|
||||
private string GetRuntime()
|
||||
{
|
||||
if (!string.IsNullOrEmpty(Runtime))
|
||||
{
|
||||
return $"/p:RuntimeIdentifier={Runtime}";
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -12,7 +12,7 @@ namespace Microsoft.DotNet.Cli.Build
|
|||
|
||||
protected override string Args
|
||||
{
|
||||
get { return $"{GetProjectPath()} {GetSource()} {GetPackages()} {GetSkipInvalidConfigurations()}"; }
|
||||
get { return $"{GetProjectPath()} {GetSource()} {GetPackages()} {GetSkipInvalidConfigurations()} {GetRuntime()}"; }
|
||||
}
|
||||
|
||||
public string ProjectPath { get; set; }
|
||||
|
@ -22,6 +22,8 @@ namespace Microsoft.DotNet.Cli.Build
|
|||
public string Packages { get; set; }
|
||||
|
||||
public bool SkipInvalidConfigurations { get; set; }
|
||||
|
||||
public string Runtime { get; set; }
|
||||
|
||||
private string GetSource()
|
||||
{
|
||||
|
@ -62,5 +64,15 @@ namespace Microsoft.DotNet.Cli.Build
|
|||
|
||||
return null;
|
||||
}
|
||||
|
||||
private string GetRuntime()
|
||||
{
|
||||
if (!string.IsNullOrEmpty(Runtime))
|
||||
{
|
||||
return $"/p:RuntimeIdentifier={Runtime}";
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -16,6 +16,8 @@ namespace Microsoft.DotNet.Tools.Test.Utilities
|
|||
|
||||
private NuGetFramework _framework;
|
||||
|
||||
private string _runtime;
|
||||
|
||||
private bool _noDependencies;
|
||||
|
||||
private DirectoryInfo _outputPath;
|
||||
|
@ -31,7 +33,7 @@ namespace Microsoft.DotNet.Tools.Test.Utilities
|
|||
|
||||
public override CommandResult Execute(string args = "")
|
||||
{
|
||||
args = $"build {GetNoDependencies()} {GetProjectFile()} {GetOutputPath()} {GetConfiguration()} {GetFramework()} {args}";
|
||||
args = $"build {GetNoDependencies()} {GetProjectFile()} {GetOutputPath()} {GetConfiguration()} {GetFramework()} {GetRuntime()} {args}";
|
||||
|
||||
if (_workingDirectory != null)
|
||||
{
|
||||
|
@ -76,6 +78,13 @@ namespace Microsoft.DotNet.Tools.Test.Utilities
|
|||
return this;
|
||||
}
|
||||
|
||||
public BuildPJCommand WithRuntime(string runtime)
|
||||
{
|
||||
_runtime = runtime;
|
||||
|
||||
return this;
|
||||
}
|
||||
|
||||
public BuildPJCommand WithNoDependencies()
|
||||
{
|
||||
_noDependencies = true;
|
||||
|
@ -131,6 +140,16 @@ namespace Microsoft.DotNet.Tools.Test.Utilities
|
|||
return $"--framework {_framework.GetShortFolderName()}";
|
||||
}
|
||||
|
||||
private string GetRuntime()
|
||||
{
|
||||
if (_runtime == null)
|
||||
{
|
||||
return null;
|
||||
}
|
||||
|
||||
return $"--runtime {_runtime}";
|
||||
}
|
||||
|
||||
private string GetNoDependencies()
|
||||
{
|
||||
if (!_noDependencies)
|
||||
|
|
|
@ -1,12 +1,6 @@
|
|||
// Copyright (c) .NET Foundation and contributors. All rights reserved.
|
||||
// Licensed under the MIT license. See LICENSE file in the project root for full license information.
|
||||
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Configuration;
|
||||
using System.IO;
|
||||
using System.Linq;
|
||||
using System.Xml.Linq;
|
||||
using FluentAssertions;
|
||||
using Microsoft.DotNet.Tools.Test.Utilities;
|
||||
using Xunit;
|
||||
|
@ -15,245 +9,31 @@ namespace Microsoft.DotNet.BindingRedirects.Tests
|
|||
{
|
||||
public class GivenAnAppWithRedirectsAndExecutableDependency : TestBase, IClassFixture<TestSetupFixture>
|
||||
{
|
||||
private const string ExecutableDependency = "dotnet-desktop-binding-redirects.exe";
|
||||
private const string ExecutableDependencyCommand = "desktop-binding-redirects";
|
||||
private TestSetupFixture _testSetup;
|
||||
public string _appWithConfigProjectRoot;
|
||||
public string _appWithoutConfigProjectRoot;
|
||||
private string _appWithConfigBuildOutput;
|
||||
private string _appWithoutConfigBuildOutput;
|
||||
private string _appWithConfigPublishOutput;
|
||||
private string _appWithoutConfigPublishOutput;
|
||||
private string _executableDependencyBuildOutput;
|
||||
private string _executableDependencyPublishOutput;
|
||||
|
||||
public GivenAnAppWithRedirectsAndExecutableDependency(TestSetupFixture testSetup)
|
||||
{
|
||||
_testSetup = testSetup;
|
||||
_appWithConfigProjectRoot = _testSetup.AppWithConfigProjectRoot;
|
||||
_appWithConfigBuildOutput = _testSetup.AppWithConfigBuildOutput;
|
||||
_appWithConfigPublishOutput = _testSetup.AppWithConfigPublishOutput;
|
||||
_appWithoutConfigProjectRoot = _testSetup.AppWithoutConfigProjectRoot;
|
||||
_appWithoutConfigBuildOutput = _testSetup.AppWithoutConfigBuildOutput;
|
||||
_appWithoutConfigPublishOutput = _testSetup.AppWithoutConfigPublishOutput;
|
||||
_executableDependencyBuildOutput = Path.Combine(Path.GetDirectoryName(_appWithConfigBuildOutput), ExecutableDependency);
|
||||
_executableDependencyPublishOutput = Path.Combine(Path.GetDirectoryName(_appWithConfigPublishOutput), ExecutableDependency);
|
||||
}
|
||||
|
||||
private static List<string> BindingsAppNoConfig
|
||||
{
|
||||
get
|
||||
{
|
||||
List<string> bindings = new List<string>()
|
||||
{
|
||||
@"<dependentAssembly xmlns=""urn:schemas-microsoft-com:asm.v1"">
|
||||
<assemblyIdentity name=""Newtonsoft.Json"" publicKeyToken=""30ad4fe6b2a6aeed"" culture=""neutral"" />
|
||||
<bindingRedirect oldVersion=""4.5.0.0"" newVersion=""8.0.0.0"" />
|
||||
<bindingRedirect oldVersion=""6.0.0.0"" newVersion=""8.0.0.0"" />
|
||||
</dependentAssembly>",
|
||||
@"<dependentAssembly xmlns=""urn:schemas-microsoft-com:asm.v1"">
|
||||
<assemblyIdentity name=""System.Web.Mvc"" publicKeyToken=""31bf3856ad364e35"" culture=""neutral"" />
|
||||
<bindingRedirect oldVersion=""4.0.0.0"" newVersion=""3.0.0.1"" />
|
||||
</dependentAssembly>"
|
||||
};
|
||||
|
||||
return bindings;
|
||||
}
|
||||
}
|
||||
|
||||
private static List<string> BindingsAppWithConfig
|
||||
{
|
||||
get
|
||||
{
|
||||
List<string> bindings = new List<string>()
|
||||
{
|
||||
@"<dependentAssembly xmlns=""urn:schemas-microsoft-com:asm.v1"">
|
||||
<assemblyIdentity name=""Newtonsoft.Json"" publicKeyToken=""30ad4fe6b2a6aeed"" culture=""neutral"" />
|
||||
<bindingRedirect oldVersion=""3.5.0.0"" newVersion=""8.0.0.0"" />
|
||||
<bindingRedirect oldVersion=""4.5.0.0"" newVersion=""8.0.0.0"" />
|
||||
<bindingRedirect oldVersion=""6.0.0.0"" newVersion=""8.0.0.0"" />
|
||||
</dependentAssembly>",
|
||||
@"<dependentAssembly xmlns=""urn:schemas-microsoft-com:asm.v1"">
|
||||
<assemblyIdentity name=""Some.Foo.Assembly"" publicKeyToken=""814f48568d36eed5"" culture=""neutral"" />
|
||||
<bindingRedirect oldVersion=""3.0.0.0"" newVersion=""5.5.5.1"" />
|
||||
</dependentAssembly>",
|
||||
@"<dependentAssembly xmlns=""urn:schemas-microsoft-com:asm.v1"">
|
||||
<assemblyIdentity name=""System.Web.Mvc"" publicKeyToken=""31bf3856ad364e35"" culture=""neutral"" />
|
||||
<bindingRedirect oldVersion=""4.0.0.0"" newVersion=""3.0.0.1"" />
|
||||
</dependentAssembly>"
|
||||
};
|
||||
|
||||
return bindings;
|
||||
}
|
||||
}
|
||||
|
||||
private static List<XElement> ExpectedBindingsAppNoConfig
|
||||
{
|
||||
get
|
||||
{
|
||||
List<XElement> bindingElements = new List<XElement>();
|
||||
|
||||
foreach (var binding in BindingsAppNoConfig)
|
||||
{
|
||||
bindingElements.Add(XElement.Parse(binding));
|
||||
}
|
||||
|
||||
return bindingElements;
|
||||
}
|
||||
}
|
||||
|
||||
private static List<XElement> ExpectedBindingsAppWithConfig
|
||||
{
|
||||
get
|
||||
{
|
||||
List<XElement> bindingElements = new List<XElement>();
|
||||
|
||||
foreach (var binding in BindingsAppWithConfig)
|
||||
{
|
||||
bindingElements.Add(XElement.Parse(binding));
|
||||
}
|
||||
|
||||
return bindingElements;
|
||||
}
|
||||
}
|
||||
|
||||
private static Dictionary<string, string> ExpectedAppSettings
|
||||
{
|
||||
get
|
||||
{
|
||||
Dictionary<string, string> appSettings = new Dictionary<string, string>()
|
||||
{
|
||||
{"Setting1", "Hello"},
|
||||
{"Setting2", "World"}
|
||||
};
|
||||
|
||||
return appSettings;
|
||||
}
|
||||
}
|
||||
|
||||
private IEnumerable<XElement> GetRedirects(string exePath)
|
||||
{
|
||||
var configFile = exePath + ".config";
|
||||
|
||||
File.Exists(configFile).Should().BeTrue($"Config file not found - {configFile}");
|
||||
|
||||
var config = ConfigurationManager.OpenExeConfiguration(exePath);
|
||||
|
||||
var runtimeSectionXml = config.Sections["runtime"].SectionInformation.GetRawXml();
|
||||
|
||||
var runtimeSectionElement = XElement.Parse(runtimeSectionXml);
|
||||
|
||||
var redirects = runtimeSectionElement.Elements()
|
||||
.Where(e => e.Name.LocalName == "assemblyBinding").Elements()
|
||||
.Where(e => e.Name.LocalName == "dependentAssembly");
|
||||
|
||||
return redirects;
|
||||
}
|
||||
|
||||
private void VerifyRedirects(IEnumerable<XElement> redirects, IEnumerable<XElement> generatedBindings)
|
||||
{
|
||||
foreach (var binding in generatedBindings)
|
||||
{
|
||||
var redirect = redirects.SingleOrDefault(r => /*XNode.DeepEquals(r, binding)*/ r.ToString() == binding.ToString());
|
||||
|
||||
redirect.Should().NotBeNull($"Binding not found in runtime section : {Environment.NewLine}{binding}");
|
||||
}
|
||||
}
|
||||
|
||||
private void VerifyAppSettings(string exePath)
|
||||
{
|
||||
var configFile = ConfigurationManager.OpenExeConfiguration(exePath);
|
||||
foreach (var appSetting in ExpectedAppSettings)
|
||||
{
|
||||
var value = configFile.AppSettings.Settings[appSetting.Key];
|
||||
value.Should().NotBeNull($"AppSetting with key '{appSetting.Key}' not found in config file.");
|
||||
value.Value.Should().Be(appSetting.Value, $"For AppSetting '{appSetting.Key}' - Expected Value '{appSetting.Value}', Actual '{ value.Value}'");
|
||||
}
|
||||
}
|
||||
|
||||
[Fact(Skip="https://github.com/dotnet/cli/issues/4514")]
|
||||
public void Build_Generates_Redirects_For_App_Without_Config()
|
||||
{
|
||||
var redirects = GetRedirects(_appWithoutConfigBuildOutput);
|
||||
VerifyRedirects(redirects, ExpectedBindingsAppNoConfig);
|
||||
|
||||
var commandResult = new TestCommand(_appWithoutConfigBuildOutput)
|
||||
.Execute();
|
||||
commandResult.Should().Pass();
|
||||
}
|
||||
|
||||
[Fact(Skip="https://github.com/dotnet/cli/issues/4514")]
|
||||
public void Publish_Generates_Redirects_For_App_Without_Config()
|
||||
{
|
||||
var redirects = GetRedirects(_appWithoutConfigPublishOutput);
|
||||
VerifyRedirects(redirects, ExpectedBindingsAppNoConfig);
|
||||
|
||||
var commandResult = new TestCommand(_appWithoutConfigPublishOutput)
|
||||
.Execute();
|
||||
commandResult.Should().Pass();
|
||||
}
|
||||
|
||||
[Fact(Skip="https://github.com/dotnet/cli/issues/4514")]
|
||||
public void Build_Generates_Redirects_For_Executable_Dependency()
|
||||
{
|
||||
var redirects = GetRedirects(_executableDependencyBuildOutput);
|
||||
VerifyRedirects(redirects, ExpectedBindingsAppNoConfig);
|
||||
|
||||
var commandResult = new TestCommand(_executableDependencyBuildOutput)
|
||||
.Execute();
|
||||
commandResult.Should().Pass();
|
||||
}
|
||||
|
||||
[Fact(Skip = "https://github.com/dotnet/cli/issues/2632")]
|
||||
public void Publish_Generates_Redirects_For_Executable_Dependency()
|
||||
{
|
||||
var redirects = GetRedirects(_executableDependencyPublishOutput);
|
||||
VerifyRedirects(redirects, ExpectedBindingsAppNoConfig);
|
||||
|
||||
var commandResult = new TestCommand(_executableDependencyPublishOutput)
|
||||
.Execute();
|
||||
commandResult.Should().Pass();
|
||||
}
|
||||
|
||||
[Fact(Skip="https://github.com/dotnet/cli/issues/4514")]
|
||||
public void Build_Generates_Redirects_For_App_With_Config()
|
||||
{
|
||||
var redirects = GetRedirects(_appWithConfigBuildOutput);
|
||||
VerifyRedirects(redirects, ExpectedBindingsAppWithConfig);
|
||||
VerifyAppSettings(_appWithConfigBuildOutput);
|
||||
|
||||
var commandResult = new TestCommand(_appWithConfigBuildOutput)
|
||||
.Execute();
|
||||
commandResult.Should().Pass();
|
||||
}
|
||||
|
||||
[Fact(Skip="https://github.com/dotnet/cli/issues/4514")]
|
||||
public void Publish_Generates_Redirects_For_App_With_Config()
|
||||
{
|
||||
var redirects = GetRedirects(_appWithConfigPublishOutput);
|
||||
VerifyRedirects(redirects, ExpectedBindingsAppWithConfig);
|
||||
VerifyAppSettings(_appWithConfigPublishOutput);
|
||||
|
||||
var commandResult = new TestCommand(_appWithConfigPublishOutput)
|
||||
.Execute();
|
||||
commandResult.Should().Pass();
|
||||
_appWithConfigProjectRoot = testSetup.AppWithConfigProjectRoot;
|
||||
_appWithoutConfigProjectRoot = testSetup.AppWithoutConfigProjectRoot;
|
||||
}
|
||||
|
||||
[Fact(Skip="https://github.com/dotnet/cli/issues/4514")]
|
||||
public void Tool_Command_Runs_Executable_Dependency_For_App_With_Config()
|
||||
{
|
||||
var commandResult = new DependencyToolInvokerCommand { WorkingDirectory = _appWithConfigProjectRoot }
|
||||
.Execute("desktop-binding-redirects", "net46", "");
|
||||
commandResult.Should().Pass();
|
||||
new DependencyToolInvokerCommand()
|
||||
.WithWorkingDirectory(_appWithConfigProjectRoot)
|
||||
.ExecuteWithCapturedOutput("desktop-binding-redirects", "net46", "")
|
||||
.Should().Pass().And.NotHaveStdErr();
|
||||
}
|
||||
|
||||
[Fact(Skip="https://github.com/dotnet/cli/issues/4514")]
|
||||
public void Tool_Command_Runs_Executable_Dependency_For_App_Without_Config()
|
||||
{
|
||||
var appDirectory = Path.GetDirectoryName(_appWithoutConfigProjectRoot);
|
||||
var commandResult = new DependencyToolInvokerCommand { WorkingDirectory = _appWithoutConfigProjectRoot }
|
||||
.Execute("desktop-binding-redirects", "net46", "");
|
||||
commandResult.Should().Pass();
|
||||
new DependencyToolInvokerCommand()
|
||||
.WithWorkingDirectory(_appWithoutConfigProjectRoot)
|
||||
.ExecuteWithCapturedOutput("desktop-binding-redirects", "net46", "")
|
||||
.Should().Pass().And.NotHaveStdErr();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
6
test/binding-redirects.Tests/NuGet.Config
Normal file
6
test/binding-redirects.Tests/NuGet.Config
Normal file
|
@ -0,0 +1,6 @@
|
|||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<configuration>
|
||||
<packageSources>
|
||||
<add key="test-packages" value="../../artifacts/testpackages" />
|
||||
</packageSources>
|
||||
</configuration>
|
|
@ -2,7 +2,7 @@
|
|||
// Licensed under the MIT license. See LICENSE file in the project root for full license information.
|
||||
|
||||
using System.IO;
|
||||
using Microsoft.DotNet.InternalAbstractions;
|
||||
using Microsoft.DotNet.Cli.Utils;
|
||||
using Microsoft.DotNet.TestFramework;
|
||||
using Microsoft.DotNet.Tools.Test.Utilities;
|
||||
using NuGet.Frameworks;
|
||||
|
@ -17,46 +17,36 @@ namespace Microsoft.DotNet.BindingRedirects.Tests
|
|||
private const string AppWithoutConfig = "AppWithRedirectsNoConfig";
|
||||
|
||||
private string _Runtime = RuntimeEnvironmentRidExtensions.GetLegacyRestoreRuntimeIdentifier();
|
||||
private string _desktopProjectsRoot = Path.Combine(RepoRoot, "TestAssets", "DesktopTestProjects");
|
||||
private string _buildRelativePath;
|
||||
private string _appWithConfigProjectRoot;
|
||||
private string _appWithConfigBuildDir;
|
||||
private string _appWithConfigPublishDir;
|
||||
private string _appWithoutConfigProjectRoot;
|
||||
private string _appWithoutConfigBuildDir;
|
||||
private string _appWithoutConfigPublishDir;
|
||||
private TestInstance _testInstance;
|
||||
private TestAssetInstance _testInstance;
|
||||
|
||||
public string AppWithConfigProjectRoot { get { return _appWithConfigProjectRoot; } }
|
||||
public string AppWithConfigBuildOutput { get; }
|
||||
public string AppWithConfigPublishOutput { get; }
|
||||
public string AppWithoutConfigProjectRoot { get { return _appWithoutConfigProjectRoot; } }
|
||||
public string AppWithoutConfigBuildOutput { get; }
|
||||
public string AppWithoutConfigPublishOutput { get; }
|
||||
|
||||
public TestSetupFixture()
|
||||
{
|
||||
_buildRelativePath = Path.Combine("bin", Config, Framework.GetShortFolderName(), _Runtime);
|
||||
var testAssetsMgr = new TestAssetsManager(_desktopProjectsRoot);
|
||||
_testInstance = testAssetsMgr.CreateTestInstance("BindingRedirectSample")
|
||||
.WithLockFiles();
|
||||
_testInstance = TestAssets.Get("DesktopTestProjects", "BindingRedirectSample")
|
||||
.CreateInstance()
|
||||
.WithSourceFiles()
|
||||
.WithNuGetConfig(new RepoDirectoriesProvider().TestPackages);
|
||||
|
||||
Setup(AppWithConfig, ref _appWithConfigProjectRoot, ref _appWithConfigBuildDir, ref _appWithConfigPublishDir);
|
||||
Setup(AppWithoutConfig, ref _appWithoutConfigProjectRoot, ref _appWithoutConfigBuildDir, ref _appWithoutConfigPublishDir);
|
||||
|
||||
AppWithConfigBuildOutput = Path.Combine(_appWithConfigBuildDir, AppWithConfig + ".exe");
|
||||
AppWithConfigPublishOutput = Path.Combine(_appWithConfigPublishDir, AppWithConfig + ".exe");
|
||||
AppWithoutConfigBuildOutput = Path.Combine(_appWithoutConfigBuildDir, AppWithoutConfig + ".exe");
|
||||
AppWithoutConfigPublishOutput = Path.Combine(_appWithoutConfigPublishDir, AppWithoutConfig + ".exe");
|
||||
_appWithConfigProjectRoot = Setup(AppWithConfig);
|
||||
_appWithoutConfigProjectRoot = Setup(AppWithoutConfig);
|
||||
}
|
||||
|
||||
private void Setup(string project, ref string projectDir, ref string buildDir, ref string publishDir)
|
||||
private string Setup(string project)
|
||||
{
|
||||
projectDir = Path.Combine(_testInstance.TestRoot, project);
|
||||
buildDir = Path.Combine(projectDir, _buildRelativePath);
|
||||
publishDir = Path.Combine(projectDir, "publish");
|
||||
string projectDir = Path.Combine(_testInstance.Root.FullName, project);
|
||||
string publishDir = Path.Combine(projectDir, "publish");
|
||||
|
||||
var buildCommand = new BuildCommand()
|
||||
new RestoreCommand()
|
||||
.WithWorkingDirectory(projectDir)
|
||||
.WithRuntime(_Runtime)
|
||||
.ExecuteWithCapturedOutput()
|
||||
.Should().Pass();
|
||||
|
||||
new BuildCommand()
|
||||
.WithWorkingDirectory(projectDir)
|
||||
.WithFramework(Framework)
|
||||
.WithRuntime(_Runtime)
|
||||
|
@ -70,6 +60,8 @@ namespace Microsoft.DotNet.BindingRedirects.Tests
|
|||
.WithRuntime(_Runtime)
|
||||
.Execute()
|
||||
.Should().Pass();
|
||||
|
||||
return projectDir;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -5,18 +5,18 @@
|
|||
"dotnet-test-xunit": "1.0.0-rc2-350904-49",
|
||||
"Microsoft.NETCore.Platforms": "1.0.1",
|
||||
"Microsoft.DotNet.PlatformAbstractions": "1.0.1-beta-000933",
|
||||
"Microsoft.DotNet.Tools.Tests.Utilities": {
|
||||
"target": "project"
|
||||
}
|
||||
"Microsoft.DotNet.Cli.Utils": { "target": "project" },
|
||||
"Microsoft.DotNet.Tools.Tests.Utilities": { "target": "project" }
|
||||
},
|
||||
"frameworks": {
|
||||
"net46": {
|
||||
"frameworkAssemblies": {
|
||||
"System.Configuration": ""
|
||||
},
|
||||
"netcoreapp1.0": {
|
||||
"dependencies": {
|
||||
"System.Console": "4.0.0"
|
||||
}
|
||||
},
|
||||
"imports": [
|
||||
"dotnet5.4",
|
||||
"portable-net451+win8"
|
||||
]
|
||||
}
|
||||
},
|
||||
"runtimes": {
|
||||
|
|
|
@ -557,6 +557,24 @@ namespace Microsoft.DotNet.Migration.Tests
|
|||
.Select(p => Path.GetFullPath(p).Substring(fullBinPath.Length));
|
||||
}
|
||||
|
||||
private static void DeleteDirectory(string dir)
|
||||
{
|
||||
foreach (string directory in Directory.EnumerateDirectories(dir))
|
||||
{
|
||||
DeleteDirectory(directory);
|
||||
}
|
||||
|
||||
try
|
||||
{
|
||||
Directory.Delete(dir, true);
|
||||
}
|
||||
catch
|
||||
{
|
||||
// retry, if still doesn't delete then throw
|
||||
Directory.Delete(dir, true);
|
||||
}
|
||||
}
|
||||
|
||||
private void CleanBinObj(string projectDirectory)
|
||||
{
|
||||
var dirs = new string[] { Path.Combine(projectDirectory, "bin"), Path.Combine(projectDirectory, "obj") };
|
||||
|
@ -565,7 +583,7 @@ namespace Microsoft.DotNet.Migration.Tests
|
|||
{
|
||||
if(Directory.Exists(dir))
|
||||
{
|
||||
Directory.Delete(dir, true);
|
||||
DeleteDirectory(dir);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -80,13 +80,17 @@ namespace Microsoft.DotNet.Cli.MSBuild.Tests
|
|||
[Fact]
|
||||
public void WhenTelemetryIsEnabledTheLoggerIsAddedToTheCommandLine()
|
||||
{
|
||||
string[] allArgs = GetArgsForMSBuild(() => true);
|
||||
Telemetry telemetry;
|
||||
string[] allArgs = GetArgsForMSBuild(() => true, out telemetry);
|
||||
// telemetry will still be disabled if environmental variable is set
|
||||
if (telemetry.Enabled)
|
||||
{
|
||||
allArgs.Should().NotBeNull();
|
||||
|
||||
allArgs.Should().NotBeNull();
|
||||
|
||||
allArgs.Should().Contain(
|
||||
value => value.IndexOf("/Logger", StringComparison.OrdinalIgnoreCase) >= 0,
|
||||
"The MSBuild logger argument should be specified when telemetry is enabled.");
|
||||
allArgs.Should().Contain(
|
||||
value => value.IndexOf("/Logger", StringComparison.OrdinalIgnoreCase) >= 0,
|
||||
"The MSBuild logger argument should be specified when telemetry is enabled.");
|
||||
}
|
||||
}
|
||||
|
||||
[Fact]
|
||||
|
@ -103,7 +107,13 @@ namespace Microsoft.DotNet.Cli.MSBuild.Tests
|
|||
|
||||
private string[] GetArgsForMSBuild(Func<bool> sentinelExists)
|
||||
{
|
||||
Telemetry telemetry = new Telemetry(new MockNuGetCacheSentinel(sentinelExists));
|
||||
Telemetry telemetry;
|
||||
return GetArgsForMSBuild(sentinelExists, out telemetry);
|
||||
}
|
||||
|
||||
private string[] GetArgsForMSBuild(Func<bool> sentinelExists, out Telemetry telemetry)
|
||||
{
|
||||
telemetry = new Telemetry(new MockNuGetCacheSentinel(sentinelExists));
|
||||
|
||||
MSBuildForwardingApp msBuildForwardingApp = new MSBuildForwardingApp(Enumerable.Empty<string>());
|
||||
|
||||
|
|
|
@ -69,9 +69,10 @@ Configuring...
|
|||
-------------------
|
||||
A command is running to initially populate your local package cache, to improve restore speed and enable offline access. This command will take up to a minute to complete and will only happen once.";
|
||||
|
||||
_firstDotnetVerbUseCommandResult.StdOut
|
||||
// normalizing line endings as git is occasionally replacing line endings in this file causing this test to fail
|
||||
NormalizeLineEndings(_firstDotnetVerbUseCommandResult.StdOut)
|
||||
.Should()
|
||||
.StartWith(firstTimeUseWelcomeMessage);
|
||||
.StartWith(NormalizeLineEndings(firstTimeUseWelcomeMessage));
|
||||
}
|
||||
|
||||
[Fact]
|
||||
|
@ -95,5 +96,10 @@ A command is running to initially populate your local package cache, to improve
|
|||
return new DotnetCommand().ExecuteWithCapturedOutput("--version").StdOut
|
||||
.TrimEnd(Environment.NewLine.ToCharArray());
|
||||
}
|
||||
|
||||
private static string NormalizeLineEndings(string s)
|
||||
{
|
||||
return s.Replace("\r\n", "\n").Replace("\r", "\n");
|
||||
}
|
||||
}
|
||||
}
|
Loading…
Reference in a new issue