Enabling VB in the CLI.
Fixing the permissions for RunVbc.sh.
This commit is contained in:
parent
6453cb4e15
commit
38fc8875f2
10 changed files with 145 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 []
|
private IEnumerable<string> _environmentVariablesToRemove = new string []
|
||||||
{
|
{
|
||||||
"CscToolExe"
|
"CscToolExe", "VbcToolExe"
|
||||||
};
|
};
|
||||||
|
|
||||||
private IEnumerable<string> _environmentVariablesToKeep = new string []
|
private IEnumerable<string> _environmentVariablesToKeep = new string []
|
||||||
|
|
|
@ -24,6 +24,7 @@ namespace Microsoft.DotNet.Cli.Utils
|
||||||
{
|
{
|
||||||
{ "MSBuildExtensionsPath", AppContext.BaseDirectory },
|
{ "MSBuildExtensionsPath", AppContext.BaseDirectory },
|
||||||
{ "CscToolExe", GetRunCscPath() },
|
{ "CscToolExe", GetRunCscPath() },
|
||||||
|
{ "VbcToolExe", GetRunVbcPath() },
|
||||||
{ "MSBuildSDKsPath", GetMSBuildSDKsPath() }
|
{ "MSBuildSDKsPath", GetMSBuildSDKsPath() }
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -77,10 +78,20 @@ namespace Microsoft.DotNet.Cli.Utils
|
||||||
SdksDirectoryName);
|
SdksDirectoryName);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private static string GetRunVbcPath()
|
||||||
|
{
|
||||||
|
return GetRunToolPath("Vbc");
|
||||||
|
}
|
||||||
|
|
||||||
private static string GetRunCscPath()
|
private static string GetRunCscPath()
|
||||||
|
{
|
||||||
|
return GetRunToolPath("Csc");
|
||||||
|
}
|
||||||
|
|
||||||
|
private static string GetRunToolPath(string compilerName)
|
||||||
{
|
{
|
||||||
var scriptExtension = RuntimeInformation.IsOSPlatform(OSPlatform.Windows) ? ".cmd" : ".sh";
|
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)" />
|
$(SharedFrameworkNameVersionPath)" />
|
||||||
</Target>
|
</Target>
|
||||||
|
|
||||||
<Target Name="RemoveVbc"
|
|
||||||
AfterTargets="CrossgenPublishDir">
|
|
||||||
<ItemGroup>
|
|
||||||
<_VbcPath Include="$(PublishDir)/**/vbc.exe" />
|
|
||||||
</ItemGroup>
|
|
||||||
|
|
||||||
<Delete Files="@(_VbcPath)" />
|
|
||||||
</Target>
|
|
||||||
|
|
||||||
<Target Name="ChmodPublishDir"
|
<Target Name="ChmodPublishDir"
|
||||||
AfterTargets="RemoveVbc"
|
AfterTargets="CrossgenPublishDir"
|
||||||
Condition=" '$(OSName)' != 'win' ">
|
Condition=" '$(OSName)' != 'win' ">
|
||||||
|
|
||||||
<Exec Command="find $(SdkOutputDirectory) -type d -exec chmod 755 {} \;" />
|
<Exec Command="find $(SdkOutputDirectory) -type d -exec chmod 755 {} \;" />
|
||||||
<Exec Command="find $(SdkOutputDirectory) -type f -exec chmod 644 {} \;" />
|
<Exec Command="find $(SdkOutputDirectory) -type f -exec chmod 644 {} \;" />
|
||||||
<Chmod Mode="755" Glob="$(SdkOutputDirectory)/Roslyn/RunCsc.sh" />
|
<Chmod Mode="755" Glob="$(SdkOutputDirectory)/Roslyn/RunCsc.sh" />
|
||||||
|
<Chmod Mode="755" Glob="$(SdkOutputDirectory)/Roslyn/RunVbc.sh" />
|
||||||
</Target>
|
</Target>
|
||||||
|
|
||||||
<Target Name="CreateSymbolsDirectory"
|
<Target Name="CreateSymbolsDirectory"
|
||||||
AfterTargets="RemoveVbc">
|
AfterTargets="CrossgenPublishDir">
|
||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
<_AllSdkFiles Include="$(PublishDir)/**/*" />
|
<_AllSdkFiles Include="$(PublishDir)/**/*" />
|
||||||
</ItemGroup>
|
</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>
|
||||||
|
|
||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
<Content Include="RunCsc.sh;RunCsc.cmd">
|
<Content Include="RunCsc.sh;RunCsc.cmd;RunVbc.sh;RunVbc.cmd">
|
||||||
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
|
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
|
||||||
<CopyToPublishDirectory>PreserveNewest</CopyToPublishDirectory>
|
<CopyToPublishDirectory>PreserveNewest</CopyToPublishDirectory>
|
||||||
</Content>
|
</Content>
|
||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
|
|
||||||
<Target Name="MakeCscRunnableAndMoveToPublishDir"
|
<Target Name="MakeCscAndVbcRunnableAndMoveToPublishDir"
|
||||||
AfterTargets="Publish"
|
AfterTargets="Publish"
|
||||||
BeforeTargets="RemoveFilesAfterPublish">
|
BeforeTargets="RemoveFilesAfterPublish">
|
||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
|
@ -48,6 +48,13 @@
|
||||||
DestinationFiles="$(PublishDir)/csc.exe;
|
DestinationFiles="$(PublishDir)/csc.exe;
|
||||||
$(PublishDir)/csc.runtimeconfig.json;
|
$(PublishDir)/csc.runtimeconfig.json;
|
||||||
$(PublishDir)/csc.deps.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>
|
||||||
|
|
||||||
<Target Name="RemoveFilesAfterPublish"
|
<Target Name="RemoveFilesAfterPublish"
|
||||||
|
|
|
@ -32,6 +32,7 @@ namespace Microsoft.DotNet.Cli.MSBuild.Tests
|
||||||
[Theory]
|
[Theory]
|
||||||
[InlineData("MSBuildExtensionsPath")]
|
[InlineData("MSBuildExtensionsPath")]
|
||||||
[InlineData("CscToolExe")]
|
[InlineData("CscToolExe")]
|
||||||
|
[InlineData("VbcToolExe")]
|
||||||
[InlineData("MSBuildSDKsPath")]
|
[InlineData("MSBuildSDKsPath")]
|
||||||
[InlineData("DOTNET_CLI_TELEMETRY_SESSIONID")]
|
[InlineData("DOTNET_CLI_TELEMETRY_SESSIONID")]
|
||||||
public void ItSetsEnvironmentalVariables(string envVarName)
|
public void ItSetsEnvironmentalVariables(string envVarName)
|
||||||
|
@ -76,6 +77,17 @@ namespace Microsoft.DotNet.Cli.MSBuild.Tests
|
||||||
.Should().NotBeNull("constructor will throw on invalid path");
|
.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]
|
[Fact]
|
||||||
public void ItSetsOrIgnoresTelemetrySessionId()
|
public void ItSetsOrIgnoresTelemetrySessionId()
|
||||||
{
|
{
|
||||||
|
|
70
test/dotnet.Tests/GivenThatICareAboutVBApps.cs
Normal file
70
test/dotnet.Tests/GivenThatICareAboutVBApps.cs
Normal file
|
@ -0,0 +1,70 @@
|
||||||
|
// 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();
|
||||||
|
}
|
||||||
|
|
||||||
|
[Fact]
|
||||||
|
public void ICanBuildVBApps()
|
||||||
|
{
|
||||||
|
new BuildCommand()
|
||||||
|
.WithWorkingDirectory(_testInstance.Root)
|
||||||
|
.Execute()
|
||||||
|
.Should().Pass();
|
||||||
|
}
|
||||||
|
|
||||||
|
[Fact]
|
||||||
|
public void ICanRunVBApps()
|
||||||
|
{
|
||||||
|
new RunCommand()
|
||||||
|
.WithWorkingDirectory(_testInstance.Root)
|
||||||
|
.Execute()
|
||||||
|
.Should().Pass();
|
||||||
|
}
|
||||||
|
|
||||||
|
[Fact]
|
||||||
|
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