commit
77177ca228
10 changed files with 148 additions and 15 deletions
7
TestAssets/TestProjects/VBTestApp/Program.vb
Normal file
7
TestAssets/TestProjects/VBTestApp/Program.vb
Normal file
|
@ -0,0 +1,7 @@
|
|||
Imports System
|
||||
|
||||
Module Program
|
||||
Sub Main(args As String())
|
||||
Console.WriteLine("Hello World!")
|
||||
End Sub
|
||||
End Module
|
8
TestAssets/TestProjects/VBTestApp/VBTestApp.vbproj
Normal file
8
TestAssets/TestProjects/VBTestApp/VBTestApp.vbproj
Normal file
|
@ -0,0 +1,8 @@
|
|||
<Project Sdk="Microsoft.NET.Sdk">
|
||||
|
||||
<PropertyGroup>
|
||||
<OutputType>Exe</OutputType>
|
||||
<TargetFramework>netcoreapp2.0</TargetFramework>
|
||||
</PropertyGroup>
|
||||
|
||||
</Project>
|
|
@ -22,7 +22,7 @@ namespace Microsoft.DotNet.Cli.Build
|
|||
|
||||
private IEnumerable<string> _environmentVariablesToRemove = new string []
|
||||
{
|
||||
"CscToolExe"
|
||||
"CscToolExe", "VbcToolExe"
|
||||
};
|
||||
|
||||
private IEnumerable<string> _environmentVariablesToKeep = new string []
|
||||
|
|
|
@ -24,6 +24,7 @@ namespace Microsoft.DotNet.Cli.Utils
|
|||
{
|
||||
{ "MSBuildExtensionsPath", AppContext.BaseDirectory },
|
||||
{ "CscToolExe", GetRunCscPath() },
|
||||
{ "VbcToolExe", GetRunVbcPath() },
|
||||
{ "MSBuildSDKsPath", GetMSBuildSDKsPath() }
|
||||
};
|
||||
|
||||
|
@ -77,10 +78,20 @@ namespace Microsoft.DotNet.Cli.Utils
|
|||
SdksDirectoryName);
|
||||
}
|
||||
|
||||
private static string GetRunVbcPath()
|
||||
{
|
||||
return GetRunToolPath("Vbc");
|
||||
}
|
||||
|
||||
private static string GetRunCscPath()
|
||||
{
|
||||
return GetRunToolPath("Csc");
|
||||
}
|
||||
|
||||
private static string GetRunToolPath(string compilerName)
|
||||
{
|
||||
var scriptExtension = RuntimeInformation.IsOSPlatform(OSPlatform.Windows) ? ".cmd" : ".sh";
|
||||
return Path.Combine(AppContext.BaseDirectory, "Roslyn", $"RunCsc{scriptExtension}");
|
||||
return Path.Combine(AppContext.BaseDirectory, "Roslyn", $"Run{compilerName}{scriptExtension}");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -201,26 +201,18 @@
|
|||
$(SharedFrameworkNameVersionPath)" />
|
||||
</Target>
|
||||
|
||||
<Target Name="RemoveVbc"
|
||||
AfterTargets="CrossgenPublishDir">
|
||||
<ItemGroup>
|
||||
<_VbcPath Include="$(PublishDir)/**/vbc.exe" />
|
||||
</ItemGroup>
|
||||
|
||||
<Delete Files="@(_VbcPath)" />
|
||||
</Target>
|
||||
|
||||
<Target Name="ChmodPublishDir"
|
||||
AfterTargets="RemoveVbc"
|
||||
AfterTargets="CrossgenPublishDir"
|
||||
Condition=" '$(OSName)' != 'win' ">
|
||||
|
||||
<Exec Command="find $(SdkOutputDirectory) -type d -exec chmod 755 {} \;" />
|
||||
<Exec Command="find $(SdkOutputDirectory) -type f -exec chmod 644 {} \;" />
|
||||
<Chmod Mode="755" Glob="$(SdkOutputDirectory)/Roslyn/RunCsc.sh" />
|
||||
<Chmod Mode="755" Glob="$(SdkOutputDirectory)/Roslyn/RunVbc.sh" />
|
||||
</Target>
|
||||
|
||||
<Target Name="CreateSymbolsDirectory"
|
||||
AfterTargets="RemoveVbc">
|
||||
AfterTargets="CrossgenPublishDir">
|
||||
<ItemGroup>
|
||||
<_AllSdkFiles Include="$(PublishDir)/**/*" />
|
||||
</ItemGroup>
|
||||
|
|
6
src/tool_roslyn/RunVbc.cmd
Normal file
6
src/tool_roslyn/RunVbc.cmd
Normal file
|
@ -0,0 +1,6 @@
|
|||
@echo off
|
||||
|
||||
REM Copyright (c) .NET Foundation and contributors. All rights reserved.
|
||||
REM Licensed under the MIT license. See LICENSE file in the project root for full license information.
|
||||
|
||||
"%~dp0..\..\..\dotnet" "%~dp0vbc.exe" %*
|
17
src/tool_roslyn/RunVbc.sh
Executable file
17
src/tool_roslyn/RunVbc.sh
Executable file
|
@ -0,0 +1,17 @@
|
|||
#!/usr/bin/env bash
|
||||
#
|
||||
# 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.
|
||||
#
|
||||
|
||||
set -e
|
||||
|
||||
SOURCE="${BASH_SOURCE[0]}"
|
||||
while [ -h "$SOURCE" ]; do # resolve $SOURCE until the file is no longer a symlink
|
||||
DIR="$( cd -P "$( dirname "$SOURCE" )" && pwd )"
|
||||
SOURCE="$(readlink "$SOURCE")"
|
||||
[[ "$SOURCE" != /* ]] && SOURCE="$DIR/$SOURCE" # if $SOURCE was a relative symlink, we need to resolve it relative to the path where the symlink file was located
|
||||
done
|
||||
DIR="$( cd -P "$( dirname "$SOURCE" )" && pwd )"
|
||||
|
||||
"$DIR/../../../dotnet" "$DIR/vbc.exe" "$@"
|
|
@ -20,13 +20,13 @@
|
|||
</ItemGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<Content Include="RunCsc.sh;RunCsc.cmd">
|
||||
<Content Include="RunCsc.sh;RunCsc.cmd;RunVbc.sh;RunVbc.cmd">
|
||||
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
|
||||
<CopyToPublishDirectory>PreserveNewest</CopyToPublishDirectory>
|
||||
</Content>
|
||||
</ItemGroup>
|
||||
|
||||
<Target Name="MakeCscRunnableAndMoveToPublishDir"
|
||||
<Target Name="MakeCscAndVbcRunnableAndMoveToPublishDir"
|
||||
AfterTargets="Publish"
|
||||
BeforeTargets="RemoveFilesAfterPublish">
|
||||
<ItemGroup>
|
||||
|
@ -48,6 +48,13 @@
|
|||
DestinationFiles="$(PublishDir)/csc.exe;
|
||||
$(PublishDir)/csc.runtimeconfig.json;
|
||||
$(PublishDir)/csc.deps.json;" />
|
||||
|
||||
<Copy SourceFiles="$(PublishDir)/runtimes/any/native/vbc.exe;
|
||||
$(PublishDir)/$(TargetName).runtimeconfig.json;
|
||||
$(PublishDir)/$(TargetName).deps.json;"
|
||||
DestinationFiles="$(PublishDir)/vbc.exe;
|
||||
$(PublishDir)/vbc.runtimeconfig.json;
|
||||
$(PublishDir)/vbc.deps.json;" />
|
||||
</Target>
|
||||
|
||||
<Target Name="RemoveFilesAfterPublish"
|
||||
|
|
|
@ -32,6 +32,7 @@ namespace Microsoft.DotNet.Cli.MSBuild.Tests
|
|||
[Theory]
|
||||
[InlineData("MSBuildExtensionsPath")]
|
||||
[InlineData("CscToolExe")]
|
||||
[InlineData("VbcToolExe")]
|
||||
[InlineData("MSBuildSDKsPath")]
|
||||
[InlineData("DOTNET_CLI_TELEMETRY_SESSIONID")]
|
||||
public void ItSetsEnvironmentalVariables(string envVarName)
|
||||
|
@ -76,6 +77,17 @@ namespace Microsoft.DotNet.Cli.MSBuild.Tests
|
|||
.Should().NotBeNull("constructor will throw on invalid path");
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void ItSetsVbcToolExePathToValidPath()
|
||||
{
|
||||
var msbuildPath = "<msbuildpath>";
|
||||
var envVar = "VbcToolExe";
|
||||
new FileInfo(new MSBuildForwardingApp(new string[0], msbuildPath)
|
||||
.GetProcessStartInfo()
|
||||
.Environment[envVar])
|
||||
.Should().NotBeNull("constructor will throw on invalid path");
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void ItSetsOrIgnoresTelemetrySessionId()
|
||||
{
|
||||
|
|
73
test/dotnet.Tests/GivenThatICareAboutVBApps.cs
Normal file
73
test/dotnet.Tests/GivenThatICareAboutVBApps.cs
Normal file
|
@ -0,0 +1,73 @@
|
|||
// 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.IO;
|
||||
using FluentAssertions;
|
||||
using Microsoft.DotNet.TestFramework;
|
||||
using Microsoft.DotNet.Tools.Test.Utilities;
|
||||
using Xunit;
|
||||
|
||||
namespace Microsoft.DotNet.Tests
|
||||
{
|
||||
public class GivenThatICareAboutVBApps : TestBase
|
||||
{
|
||||
private TestAssetInstance _testInstance;
|
||||
|
||||
public GivenThatICareAboutVBApps()
|
||||
{
|
||||
_testInstance = TestAssets.Get("VBTestApp")
|
||||
.CreateInstance()
|
||||
.WithSourceFiles();
|
||||
|
||||
new RestoreCommand()
|
||||
.WithWorkingDirectory(_testInstance.Root)
|
||||
.Execute()
|
||||
.Should().Pass();
|
||||
}
|
||||
|
||||
// Enable cross-plat once https://github.com/Microsoft/msbuild/issues/422 is fixed
|
||||
[WindowsOnlyFact]
|
||||
public void ICanBuildVBApps()
|
||||
{
|
||||
new BuildCommand()
|
||||
.WithWorkingDirectory(_testInstance.Root)
|
||||
.Execute()
|
||||
.Should().Pass();
|
||||
}
|
||||
|
||||
// Enable cross-plat once https://github.com/Microsoft/msbuild/issues/422 is fixed
|
||||
[WindowsOnlyFact]
|
||||
public void ICanRunVBApps()
|
||||
{
|
||||
new RunCommand()
|
||||
.WithWorkingDirectory(_testInstance.Root)
|
||||
.Execute()
|
||||
.Should().Pass();
|
||||
}
|
||||
|
||||
// Enable cross-plat once https://github.com/Microsoft/msbuild/issues/422 is fixed
|
||||
[WindowsOnlyFact]
|
||||
public void ICanPublicAndRunVBApps()
|
||||
{
|
||||
new PublishCommand()
|
||||
.WithWorkingDirectory(_testInstance.Root)
|
||||
.Execute()
|
||||
.Should().Pass();
|
||||
|
||||
var configuration = Environment.GetEnvironmentVariable("CONFIGURATION") ?? "Debug";
|
||||
var outputDll = Path.Combine(
|
||||
_testInstance.Root.FullName,
|
||||
"bin",
|
||||
configuration,
|
||||
"netcoreapp2.0",
|
||||
"publish",
|
||||
"VBTestApp.dll");
|
||||
|
||||
new DotnetCommand()
|
||||
.ExecuteWithCapturedOutput(outputDll)
|
||||
.Should().Pass()
|
||||
.And.HaveStdOutContaining("Hello World");
|
||||
}
|
||||
}
|
||||
}
|
Loading…
Add table
Reference in a new issue