Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion src/Dotnet.Script.Core/ScriptPublisher.cs
Original file line number Diff line number Diff line change
Expand Up @@ -88,7 +88,7 @@ public void CreateExecutable<TReturn, THost>(ScriptContext context, LogFactory l

var commandRunner = new CommandRunner(logFactory);
// todo: may want to add ability to return dotnet.exe errors
var exitcode = commandRunner.Execute("dotnet", $"publish \"{renamedProjectPath}\" -c Release -r {runtimeIdentifier} -o \"{context.WorkingDirectory}\" {(ScriptEnvironment.Default.TargetFramework == "netcoreapp3.0" ? "/p:PublishSingleFile=true" : "")} /p:DebugType=Embedded");
var exitcode = commandRunner.Execute("dotnet", $"publish \"{renamedProjectPath}\" -c Release -r {runtimeIdentifier} -o \"{context.WorkingDirectory}\" {(ScriptEnvironment.Default.NetCoreVersion.Major >= 3 ? "/p:PublishSingleFile=true" : string.Empty)} /p:DebugType=Embedded");

if (exitcode != 0)
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@ public ScriptDependencyContext ReadDependencyContext(string pathToAssetsFile)
}
}

if (ScriptEnvironment.Default.NetCoreVersion.Version.StartsWith("3"))
if (ScriptEnvironment.Default.NetCoreVersion.Major >= 3)
{
var netcoreAppRuntimeAssemblyLocation = Path.GetDirectoryName(typeof(object).Assembly.Location);
var netcoreAppRuntimeAssemblies = Directory.GetFiles(netcoreAppRuntimeAssemblyLocation, "*.dll").Where(IsAssembly).ToArray();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,7 @@ private static DotnetVersion GetNetCoreAppVersion()
{
// https://github.com/dotnet/BenchmarkDotNet/blob/94863ab4d024eca04d061423e5aad498feff386b/src/BenchmarkDotNet/Portability/RuntimeInformation.cs#L156
var codeBase = typeof(System.Runtime.GCSettings).GetTypeInfo().Assembly.CodeBase;
var pattern = @"^.*Microsoft\.NETCore\.App\/(\d\.\d)(.*?)\/";
var pattern = @"^.*Microsoft\.NETCore\.App\/(\d+\.\d+)(.*?)\/";
var match = Regex.Match(codeBase, pattern, RegexOptions.IgnoreCase);
if (!match.Success)
{
Expand Down Expand Up @@ -139,9 +139,17 @@ public DotnetVersion(string version, string tfm)
{
Version = version;
Tfm = tfm;

var versionMatch = Regex.Match(input: Version, pattern: @"^(\d+)(?:\.(\d+))?");
if (versionMatch.Success && versionMatch.Groups[1].Success)
Major = int.Parse(versionMatch.Groups[1].Value);
if (versionMatch.Success && versionMatch.Groups[2].Success)
Minor = int.Parse(versionMatch.Groups[2].Value);
}

public string Version { get; }
public string Tfm { get; }
public int Major { get; }
public int Minor { get; }
}
}
7 changes: 4 additions & 3 deletions src/Dotnet.Script.Tests/ScriptPublisherTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -40,10 +40,11 @@ public void SimplePublishTest()

Assert.Equal(0, executableRunResult);

#if NETCOREAPP3_0
var publishedFiles = Directory.EnumerateFiles(Path.Combine(workspaceFolder.Path, "publish", _scriptEnvironment.RuntimeIdentifier));
Assert.True(1 == publishedFiles.Count(), "There should be only a single published file on .NET Core 3.0");
#endif
if (_scriptEnvironment.NetCoreVersion.Major >= 3)
Assert.True(publishedFiles.Count() == 1, "There should be only a single published file");
else
Assert.True(publishedFiles.Count() > 1, "There should be multiple published files");
}
}

Expand Down