From 38fc8875f26a351747a638cf95b5e74e28d054ef Mon Sep 17 00:00:00 2001 From: Livar Cunha Date: Wed, 17 May 2017 16:05:22 -0700 Subject: [PATCH] Enabling VB in the CLI. Fixing the permissions for RunVbc.sh. --- TestAssets/TestProjects/VBTestApp/Program.vb | 7 ++ .../TestProjects/VBTestApp/VBTestApp.vbproj | 8 +++ .../EnvironmentVariableFilter.cs | 2 +- .../MSBuildForwardingAppWithoutLogging.cs | 13 +++- src/redist/redist.csproj | 14 +--- src/tool_roslyn/RunVbc.cmd | 6 ++ src/tool_roslyn/RunVbc.sh | 17 +++++ src/tool_roslyn/tool_roslyn.csproj | 11 ++- .../GivenMsbuildForwardingApp.cs | 12 ++++ .../dotnet.Tests/GivenThatICareAboutVBApps.cs | 70 +++++++++++++++++++ 10 files changed, 145 insertions(+), 15 deletions(-) create mode 100644 TestAssets/TestProjects/VBTestApp/Program.vb create mode 100644 TestAssets/TestProjects/VBTestApp/VBTestApp.vbproj create mode 100644 src/tool_roslyn/RunVbc.cmd create mode 100755 src/tool_roslyn/RunVbc.sh create mode 100644 test/dotnet.Tests/GivenThatICareAboutVBApps.cs diff --git a/TestAssets/TestProjects/VBTestApp/Program.vb b/TestAssets/TestProjects/VBTestApp/Program.vb new file mode 100644 index 000000000..46283ca23 --- /dev/null +++ b/TestAssets/TestProjects/VBTestApp/Program.vb @@ -0,0 +1,7 @@ +Imports System + +Module Program + Sub Main(args As String()) + Console.WriteLine("Hello World!") + End Sub +End Module diff --git a/TestAssets/TestProjects/VBTestApp/VBTestApp.vbproj b/TestAssets/TestProjects/VBTestApp/VBTestApp.vbproj new file mode 100644 index 000000000..ce1697ae8 --- /dev/null +++ b/TestAssets/TestProjects/VBTestApp/VBTestApp.vbproj @@ -0,0 +1,8 @@ + + + + Exe + netcoreapp2.0 + + + diff --git a/build_projects/dotnet-cli-build/EnvironmentVariableFilter.cs b/build_projects/dotnet-cli-build/EnvironmentVariableFilter.cs index d5a7a5acf..5d5cdf9e3 100644 --- a/build_projects/dotnet-cli-build/EnvironmentVariableFilter.cs +++ b/build_projects/dotnet-cli-build/EnvironmentVariableFilter.cs @@ -22,7 +22,7 @@ namespace Microsoft.DotNet.Cli.Build private IEnumerable _environmentVariablesToRemove = new string [] { - "CscToolExe" + "CscToolExe", "VbcToolExe" }; private IEnumerable _environmentVariablesToKeep = new string [] diff --git a/src/Microsoft.DotNet.Cli.Utils/MSBuildForwardingAppWithoutLogging.cs b/src/Microsoft.DotNet.Cli.Utils/MSBuildForwardingAppWithoutLogging.cs index 351ce43af..500ab7b30 100644 --- a/src/Microsoft.DotNet.Cli.Utils/MSBuildForwardingAppWithoutLogging.cs +++ b/src/Microsoft.DotNet.Cli.Utils/MSBuildForwardingAppWithoutLogging.cs @@ -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}"); } } } diff --git a/src/redist/redist.csproj b/src/redist/redist.csproj index 02b89f3cb..f9fdbf181 100644 --- a/src/redist/redist.csproj +++ b/src/redist/redist.csproj @@ -201,26 +201,18 @@ $(SharedFrameworkNameVersionPath)" /> - - - <_VbcPath Include="$(PublishDir)/**/vbc.exe" /> - - - - - + + AfterTargets="CrossgenPublishDir"> <_AllSdkFiles Include="$(PublishDir)/**/*" /> diff --git a/src/tool_roslyn/RunVbc.cmd b/src/tool_roslyn/RunVbc.cmd new file mode 100644 index 000000000..e891b1bf5 --- /dev/null +++ b/src/tool_roslyn/RunVbc.cmd @@ -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" %* diff --git a/src/tool_roslyn/RunVbc.sh b/src/tool_roslyn/RunVbc.sh new file mode 100755 index 000000000..3dda886a0 --- /dev/null +++ b/src/tool_roslyn/RunVbc.sh @@ -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" "$@" diff --git a/src/tool_roslyn/tool_roslyn.csproj b/src/tool_roslyn/tool_roslyn.csproj index a33ff9b17..b99d2818a 100644 --- a/src/tool_roslyn/tool_roslyn.csproj +++ b/src/tool_roslyn/tool_roslyn.csproj @@ -20,13 +20,13 @@ - + PreserveNewest PreserveNewest - @@ -48,6 +48,13 @@ DestinationFiles="$(PublishDir)/csc.exe; $(PublishDir)/csc.runtimeconfig.json; $(PublishDir)/csc.deps.json;" /> + +