Change stub packages to no longer contain any dependencies. Instead they just contain a dummy.txt file.
This commit is contained in:
parent
85a4e44fa2
commit
4b14c8471c
1 changed files with 9 additions and 35 deletions
|
@ -1,16 +1,7 @@
|
||||||
using System;
|
|
||||||
using System.Collections.Generic;
|
|
||||||
using System.IO;
|
using System.IO;
|
||||||
using System.Linq;
|
|
||||||
using System.Net.Http;
|
|
||||||
using System.Text;
|
using System.Text;
|
||||||
using Microsoft.DotNet.Cli.Build.Framework;
|
|
||||||
using Microsoft.WindowsAzure.Storage;
|
|
||||||
using Microsoft.WindowsAzure.Storage.Blob;
|
|
||||||
using Microsoft.DotNet.Cli.Build;
|
using Microsoft.DotNet.Cli.Build;
|
||||||
|
|
||||||
using static Microsoft.DotNet.Cli.Build.Framework.BuildHelpers;
|
|
||||||
|
|
||||||
namespace Microsoft.DotNet.Host.Build
|
namespace Microsoft.DotNet.Host.Build
|
||||||
{
|
{
|
||||||
public class StubPackageBuilder
|
public class StubPackageBuilder
|
||||||
|
@ -19,7 +10,7 @@ namespace Microsoft.DotNet.Host.Build
|
||||||
private string _intermediateDirectory;
|
private string _intermediateDirectory;
|
||||||
private string _outputDirectory;
|
private string _outputDirectory;
|
||||||
|
|
||||||
private bool _stubBitsBuilt = false;
|
private bool _dummyFileCreated;
|
||||||
|
|
||||||
public StubPackageBuilder(DotNetCli dotnet, string intermediateDirectory, string outputDirectory)
|
public StubPackageBuilder(DotNetCli dotnet, string intermediateDirectory, string outputDirectory)
|
||||||
{
|
{
|
||||||
|
@ -30,45 +21,28 @@ namespace Microsoft.DotNet.Host.Build
|
||||||
|
|
||||||
public void GeneratePackage(string packageId, string version)
|
public void GeneratePackage(string packageId, string version)
|
||||||
{
|
{
|
||||||
if (! _stubBitsBuilt)
|
if (!_dummyFileCreated)
|
||||||
{
|
{
|
||||||
BuildStubBits(_dotnet, _intermediateDirectory);
|
CreateDummyFile(_dotnet, _intermediateDirectory);
|
||||||
}
|
}
|
||||||
|
|
||||||
CreateStubPackage(_dotnet, packageId, version, _intermediateDirectory, _outputDirectory);
|
CreateStubPackage(_dotnet, packageId, version, _intermediateDirectory, _outputDirectory);
|
||||||
}
|
}
|
||||||
|
|
||||||
private void BuildStubBits(DotNetCli dotnet, string intermediateDirectory)
|
private void CreateDummyFile(DotNetCli dotnet, string intermediateDirectory)
|
||||||
{
|
{
|
||||||
var projectJson = new StringBuilder();
|
var dummyTxt = "dummy text";
|
||||||
projectJson.Append("{");
|
|
||||||
projectJson.Append(" \"dependencies\": { \"System.Console\": \"4.0.0-*\" },");
|
|
||||||
projectJson.Append(" \"frameworks\": { \"netcoreapp1.0\": { } },");
|
|
||||||
projectJson.Append("}");
|
|
||||||
|
|
||||||
var programCs = "using System; namespace ConsoleApplication { public class Program { public static void Main(string[] args) { Console.WriteLine(\"Hello World!\"); } } }";
|
|
||||||
|
|
||||||
var tempPjDirectory = Path.Combine(intermediateDirectory, "dummyNuGetPackageIntermediate");
|
var tempPjDirectory = Path.Combine(intermediateDirectory, "dummyNuGetPackageIntermediate");
|
||||||
FS.Rmdir(tempPjDirectory);
|
FS.Rmdir(tempPjDirectory);
|
||||||
|
|
||||||
Directory.CreateDirectory(tempPjDirectory);
|
Directory.CreateDirectory(tempPjDirectory);
|
||||||
|
|
||||||
var tempPjFile = Path.Combine(tempPjDirectory, "project.json");
|
var dummyTextFile = Path.Combine(tempPjDirectory, "dummy.txt");
|
||||||
var tempSourceFile = Path.Combine(tempPjDirectory, "Program.cs");
|
|
||||||
|
|
||||||
File.WriteAllText(tempPjFile, projectJson.ToString());
|
File.WriteAllText(dummyTextFile, dummyTxt);
|
||||||
File.WriteAllText(tempSourceFile, programCs.ToString());
|
|
||||||
|
|
||||||
dotnet.Restore("--verbosity", "verbose", "--disable-parallel")
|
_dummyFileCreated = true;
|
||||||
.WorkingDirectory(tempPjDirectory)
|
|
||||||
.Execute()
|
|
||||||
.EnsureSuccessful();
|
|
||||||
dotnet.Build(tempPjFile, "--runtime", "win7-x64")
|
|
||||||
.WorkingDirectory(tempPjDirectory)
|
|
||||||
.Execute()
|
|
||||||
.EnsureSuccessful();
|
|
||||||
|
|
||||||
_stubBitsBuilt = true;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private static void CreateStubPackage(DotNetCli dotnet,
|
private static void CreateStubPackage(DotNetCli dotnet,
|
||||||
|
@ -81,7 +55,7 @@ namespace Microsoft.DotNet.Host.Build
|
||||||
projectJson.Append("{");
|
projectJson.Append("{");
|
||||||
projectJson.Append($" \"version\": \"{version}\",");
|
projectJson.Append($" \"version\": \"{version}\",");
|
||||||
projectJson.Append($" \"name\": \"{packageId}\",");
|
projectJson.Append($" \"name\": \"{packageId}\",");
|
||||||
projectJson.Append(" \"dependencies\": { \"System.Console\": \"4.0.0-*\" },");
|
projectJson.Append(" \"packOptions\": { \"files\": { \"include\": \"dummy.txt\" } },");
|
||||||
projectJson.Append(" \"frameworks\": { \"netcoreapp1.0\": { } },");
|
projectJson.Append(" \"frameworks\": { \"netcoreapp1.0\": { } },");
|
||||||
projectJson.Append("}");
|
projectJson.Append("}");
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue