Skip to content
This repository was archived by the owner on Apr 20, 2023. It is now read-only.

Commit 38fc887

Browse files
Livar Cunhalivarcocc
authored andcommitted
Enabling VB in the CLI.
Fixing the permissions for RunVbc.sh.
1 parent 6453cb4 commit 38fc887

File tree

10 files changed

+145
-15
lines changed

10 files changed

+145
-15
lines changed
Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
Imports System
2+
3+
Module Program
4+
Sub Main(args As String())
5+
Console.WriteLine("Hello World!")
6+
End Sub
7+
End Module
Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
<Project Sdk="Microsoft.NET.Sdk">
2+
3+
<PropertyGroup>
4+
<OutputType>Exe</OutputType>
5+
<TargetFramework>netcoreapp2.0</TargetFramework>
6+
</PropertyGroup>
7+
8+
</Project>

build_projects/dotnet-cli-build/EnvironmentVariableFilter.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ public class EnvironmentFilter
2222

2323
private IEnumerable<string> _environmentVariablesToRemove = new string []
2424
{
25-
"CscToolExe"
25+
"CscToolExe", "VbcToolExe"
2626
};
2727

2828
private IEnumerable<string> _environmentVariablesToKeep = new string []

src/Microsoft.DotNet.Cli.Utils/MSBuildForwardingAppWithoutLogging.cs

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,7 @@ internal class MSBuildForwardingAppWithoutLogging
2424
{
2525
{ "MSBuildExtensionsPath", AppContext.BaseDirectory },
2626
{ "CscToolExe", GetRunCscPath() },
27+
{ "VbcToolExe", GetRunVbcPath() },
2728
{ "MSBuildSDKsPath", GetMSBuildSDKsPath() }
2829
};
2930

@@ -77,10 +78,20 @@ private static string GetMSBuildSDKsPath()
7778
SdksDirectoryName);
7879
}
7980

81+
private static string GetRunVbcPath()
82+
{
83+
return GetRunToolPath("Vbc");
84+
}
85+
8086
private static string GetRunCscPath()
87+
{
88+
return GetRunToolPath("Csc");
89+
}
90+
91+
private static string GetRunToolPath(string compilerName)
8192
{
8293
var scriptExtension = RuntimeInformation.IsOSPlatform(OSPlatform.Windows) ? ".cmd" : ".sh";
83-
return Path.Combine(AppContext.BaseDirectory, "Roslyn", $"RunCsc{scriptExtension}");
94+
return Path.Combine(AppContext.BaseDirectory, "Roslyn", $"Run{compilerName}{scriptExtension}");
8495
}
8596
}
8697
}

src/redist/redist.csproj

Lines changed: 3 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -201,26 +201,18 @@
201201
$(SharedFrameworkNameVersionPath)" />
202202
</Target>
203203

204-
<Target Name="RemoveVbc"
205-
AfterTargets="CrossgenPublishDir">
206-
<ItemGroup>
207-
<_VbcPath Include="$(PublishDir)/**/vbc.exe" />
208-
</ItemGroup>
209-
210-
<Delete Files="@(_VbcPath)" />
211-
</Target>
212-
213204
<Target Name="ChmodPublishDir"
214-
AfterTargets="RemoveVbc"
205+
AfterTargets="CrossgenPublishDir"
215206
Condition=" '$(OSName)' != 'win' ">
216207

217208
<Exec Command="find $(SdkOutputDirectory) -type d -exec chmod 755 {} \;" />
218209
<Exec Command="find $(SdkOutputDirectory) -type f -exec chmod 644 {} \;" />
219210
<Chmod Mode="755" Glob="$(SdkOutputDirectory)/Roslyn/RunCsc.sh" />
211+
<Chmod Mode="755" Glob="$(SdkOutputDirectory)/Roslyn/RunVbc.sh" />
220212
</Target>
221213

222214
<Target Name="CreateSymbolsDirectory"
223-
AfterTargets="RemoveVbc">
215+
AfterTargets="CrossgenPublishDir">
224216
<ItemGroup>
225217
<_AllSdkFiles Include="$(PublishDir)/**/*" />
226218
</ItemGroup>

src/tool_roslyn/RunVbc.cmd

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
@echo off
2+
3+
REM Copyright (c) .NET Foundation and contributors. All rights reserved.
4+
REM Licensed under the MIT license. See LICENSE file in the project root for full license information.
5+
6+
"%~dp0..\..\..\dotnet" "%~dp0vbc.exe" %*

src/tool_roslyn/RunVbc.sh

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
#!/usr/bin/env bash
2+
#
3+
# Copyright (c) .NET Foundation and contributors. All rights reserved.
4+
# Licensed under the MIT license. See LICENSE file in the project root for full license information.
5+
#
6+
7+
set -e
8+
9+
SOURCE="${BASH_SOURCE[0]}"
10+
while [ -h "$SOURCE" ]; do # resolve $SOURCE until the file is no longer a symlink
11+
DIR="$( cd -P "$( dirname "$SOURCE" )" && pwd )"
12+
SOURCE="$(readlink "$SOURCE")"
13+
[[ "$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
14+
done
15+
DIR="$( cd -P "$( dirname "$SOURCE" )" && pwd )"
16+
17+
"$DIR/../../../dotnet" "$DIR/vbc.exe" "$@"

src/tool_roslyn/tool_roslyn.csproj

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -20,13 +20,13 @@
2020
</ItemGroup>
2121

2222
<ItemGroup>
23-
<Content Include="RunCsc.sh;RunCsc.cmd">
23+
<Content Include="RunCsc.sh;RunCsc.cmd;RunVbc.sh;RunVbc.cmd">
2424
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
2525
<CopyToPublishDirectory>PreserveNewest</CopyToPublishDirectory>
2626
</Content>
2727
</ItemGroup>
2828

29-
<Target Name="MakeCscRunnableAndMoveToPublishDir"
29+
<Target Name="MakeCscAndVbcRunnableAndMoveToPublishDir"
3030
AfterTargets="Publish"
3131
BeforeTargets="RemoveFilesAfterPublish">
3232
<ItemGroup>
@@ -48,6 +48,13 @@
4848
DestinationFiles="$(PublishDir)/csc.exe;
4949
$(PublishDir)/csc.runtimeconfig.json;
5050
$(PublishDir)/csc.deps.json;" />
51+
52+
<Copy SourceFiles="$(PublishDir)/runtimes/any/native/vbc.exe;
53+
$(PublishDir)/$(TargetName).runtimeconfig.json;
54+
$(PublishDir)/$(TargetName).deps.json;"
55+
DestinationFiles="$(PublishDir)/vbc.exe;
56+
$(PublishDir)/vbc.runtimeconfig.json;
57+
$(PublishDir)/vbc.deps.json;" />
5158
</Target>
5259

5360
<Target Name="RemoveFilesAfterPublish"

test/dotnet-msbuild.Tests/GivenMsbuildForwardingApp.cs

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,7 @@ public void DotnetIsExecuted()
3232
[Theory]
3333
[InlineData("MSBuildExtensionsPath")]
3434
[InlineData("CscToolExe")]
35+
[InlineData("VbcToolExe")]
3536
[InlineData("MSBuildSDKsPath")]
3637
[InlineData("DOTNET_CLI_TELEMETRY_SESSIONID")]
3738
public void ItSetsEnvironmentalVariables(string envVarName)
@@ -76,6 +77,17 @@ public void ItSetsCscToolExePathToValidPath()
7677
.Should().NotBeNull("constructor will throw on invalid path");
7778
}
7879

80+
[Fact]
81+
public void ItSetsVbcToolExePathToValidPath()
82+
{
83+
var msbuildPath = "<msbuildpath>";
84+
var envVar = "VbcToolExe";
85+
new FileInfo(new MSBuildForwardingApp(new string[0], msbuildPath)
86+
.GetProcessStartInfo()
87+
.Environment[envVar])
88+
.Should().NotBeNull("constructor will throw on invalid path");
89+
}
90+
7991
[Fact]
8092
public void ItSetsOrIgnoresTelemetrySessionId()
8193
{
Lines changed: 70 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,70 @@
1+
// Copyright (c) .NET Foundation and contributors. All rights reserved. 
2+
// Licensed under the MIT license. See LICENSE file in the project root for full license information. 
3+
4+
using System;
5+
using System.IO;
6+
using FluentAssertions;
7+
using Microsoft.DotNet.TestFramework;
8+
using Microsoft.DotNet.Tools.Test.Utilities;
9+
using Xunit;
10+
11+
namespace Microsoft.DotNet.Tests
12+
{
13+
public class GivenThatICareAboutVBApps : TestBase
14+
{
15+
private TestAssetInstance _testInstance;
16+
17+
public GivenThatICareAboutVBApps()
18+
{
19+
_testInstance = TestAssets.Get("VBTestApp")
20+
.CreateInstance()
21+
.WithSourceFiles();
22+
23+
new RestoreCommand()
24+
.WithWorkingDirectory(_testInstance.Root)
25+
.Execute()
26+
.Should().Pass();
27+
}
28+
29+
[Fact]
30+
public void ICanBuildVBApps()
31+
{
32+
new BuildCommand()
33+
.WithWorkingDirectory(_testInstance.Root)
34+
.Execute()
35+
.Should().Pass();
36+
}
37+
38+
[Fact]
39+
public void ICanRunVBApps()
40+
{
41+
new RunCommand()
42+
.WithWorkingDirectory(_testInstance.Root)
43+
.Execute()
44+
.Should().Pass();
45+
}
46+
47+
[Fact]
48+
public void ICanPublicAndRunVBApps()
49+
{
50+
new PublishCommand()
51+
.WithWorkingDirectory(_testInstance.Root)
52+
.Execute()
53+
.Should().Pass();
54+
55+
var configuration = Environment.GetEnvironmentVariable("CONFIGURATION") ?? "Debug";
56+
var outputDll = Path.Combine(
57+
_testInstance.Root.FullName,
58+
"bin",
59+
configuration,
60+
"netcoreapp2.0",
61+
"publish",
62+
"VBTestApp.dll");
63+
64+
new DotnetCommand()
65+
.ExecuteWithCapturedOutput(outputDll)
66+
.Should().Pass()
67+
.And.HaveStdOutContaining("Hello World");
68+
}
69+
}
70+
}

0 commit comments

Comments
 (0)