Skip to content

Commit

Permalink
Initial porting work to .NET and ASP.NET Core, but still getting buil…
Browse files Browse the repository at this point in the history
…d errors, might be related to the use of dnx to compile code on the website.
  • Loading branch information
clarkis117 committed Jun 30, 2016
1 parent 75ea0bb commit 13a52c9
Show file tree
Hide file tree
Showing 17 changed files with 15,836 additions and 18,322 deletions.
9 changes: 4 additions & 5 deletions global.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
{
"projects": [ "src", "test" ],
"sdk": {
"version": "1.0.0-rc1-update1",
"runtime": "coreclr"
}
"projects": [ "src", "test" ],
"sdk": {
"version": "1.0.0-preview2-003121"
}
}
10 changes: 6 additions & 4 deletions src/GenFu.Web/Controllers/HomeController.cs
Original file line number Diff line number Diff line change
Expand Up @@ -4,19 +4,21 @@
using System.Text;
using System.Threading.Tasks;
using GenFu.Web.Models;
using Microsoft.AspNet.Http;
using Microsoft.AspNet.Mvc;
using Microsoft.AspNetCore.Http;
using Microsoft.AspNetCore.Mvc;
using Microsoft.Dnx.Compilation;
using Microsoft.Dnx.Runtime;
//using Microsoft.DotNet.Tools.Compiler;
using Microsoft.Extensions.PlatformAbstractions;
//using Microsoft.VisualStudio.Web.CodeGeneration.DotNet;
using Newtonsoft.Json;

namespace GenFu.Web.Controllers
{
public class HomeController : Controller
{
private const string RandomObjectsSessionKey = nameof(GenerateDataModel.RandomObjects);

//IAssemblyLoadContextAccessor accessor
private readonly IAssemblyLoadContextAccessor _accessor;
private readonly ILibraryExporter _exporter;

Expand Down Expand Up @@ -78,7 +80,7 @@ public IActionResult Download()

if (randomObjectsJson == null)
{
return HttpBadRequest();
return BadRequest();
}

var randomObjectsJsonAsBytes = new UTF8Encoding().GetBytes(randomObjectsJson);
Expand Down
2 changes: 1 addition & 1 deletion src/GenFu.Web/GenFu.Web.xproj
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
<ProjectGuid>8bf0dfe7-71da-4387-a416-78ac1cb3c41b</ProjectGuid>
<RootNamespace>GenFu.Web</RootNamespace>
<BaseIntermediateOutputPath Condition="'$(BaseIntermediateOutputPath)'=='' ">..\artifacts\obj\$(MSBuildProjectName)</BaseIntermediateOutputPath>
<OutputPath Condition="'$(OutputPath)'=='' ">..\artifacts\bin\$(MSBuildProjectName)\</OutputPath>
<OutputPath Condition="'$(OutputPath)'=='' ">.\bin\</OutputPath>
</PropertyGroup>
<PropertyGroup>
<SchemaVersion>2.0</SchemaVersion>
Expand Down
4 changes: 2 additions & 2 deletions src/GenFu.Web/Helpers/ViewHelpers.cs
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@

using Microsoft.AspNet.Mvc.Rendering;
using Microsoft.AspNetCore.Mvc.Rendering;
using System;
using Microsoft.AspNet.Mvc.ViewFeatures;
using Microsoft.AspNetCore.Mvc.ViewFeatures;

namespace GenFu.Web.Helpers
{
Expand Down
12 changes: 6 additions & 6 deletions src/GenFu.Web/Models/SourceCode.cs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
using Microsoft.AspNet.Mvc.Razor;
using Microsoft.AspNetCore.Mvc.Razor;
using Microsoft.CodeAnalysis;
using Microsoft.CodeAnalysis.CSharp;
using Microsoft.CodeAnalysis.Emit;
Expand All @@ -18,9 +18,9 @@ namespace GenFu.Web.Models
{
public class SourceCode
{
// todo: make not hacky
public IAssemblyLoadContextAccessor Accessor { get; set; }
public ILibraryExporter LibraryExporter { get; set; }
// todo: make not hacky
public IAssemblyLoadContextAccessor Accessor { get; set; }
public ILibraryExporter LibraryExporter { get; set; }
private Type _compiledType;
private bool _isCompiled;

Expand Down Expand Up @@ -72,8 +72,8 @@ public CompileResult Compile()

// build references up
var references = new List<MetadataReference>();
//typeof(object).GetTypeInfo().Assembly.GetName().Name
var export = LibraryExporter.GetAllExports("GenFu.Web");
//typeof(object).GetTypeInfo().Assembly.GetName().Name
var export = LibraryExporter.GetAllExports("GenFu.Web");
foreach (var reference in export.MetadataReferences.Where(r=> r.Name == "System.Runtime"))
{
references.Add(reference.ConvertMetadataReference(MetadataReferenceExtensions.CreateAssemblyMetadata));
Expand Down
33 changes: 29 additions & 4 deletions src/GenFu.Web/Startup.cs
Original file line number Diff line number Diff line change
@@ -1,8 +1,9 @@
using Microsoft.AspNet.Builder;
using Microsoft.AspNet.Hosting;
using Microsoft.AspNetCore.Builder;
using Microsoft.AspNetCore.Hosting;
using Microsoft.Extensions.DependencyInjection;
using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;

namespace GenFu.Web
Expand All @@ -12,7 +13,7 @@ public class Startup
public void ConfigureServices(IServiceCollection services)
{
services.AddMvc();
services.AddCaching();
services.AddMemoryCache();
services.AddSession(s =>
{
s.IdleTimeout = TimeSpan.FromMinutes(1);
Expand All @@ -29,7 +30,7 @@ public void Configure(IApplicationBuilder app, IHostingEnvironment env)
}

// Add the platform handler to the request pipeline.
app.UseIISPlatformHandler();
// app.UseIISPlatformHandler();
app.UseStaticFiles();
app.UseSession();

Expand All @@ -42,4 +43,28 @@ public void Configure(IApplicationBuilder app, IHostingEnvironment env)

}
}

public class Program
{
public static IWebHostBuilder getBuilder(string[] args)
{
var host = new WebHostBuilder()
.UseContentRoot(Directory.GetCurrentDirectory())
.UseIISIntegration()
.UseKestrel()
.UseStartup<Startup>();
//.Build();

return host;
}

public static void Main(string[] args)
{
var host = getBuilder(args);

host.Build().Run();

//todo make do keep alive and logging here
}
}
}
85 changes: 55 additions & 30 deletions src/GenFu.Web/project.json
Original file line number Diff line number Diff line change
@@ -1,36 +1,61 @@
{
"webroot": "wwwroot",
"version": "1.0.0-*",
"webroot": "wwwroot",
"version": "1.0.0-*",

"dependencies": {
"GenFu": "",
"Microsoft.AspNet.Diagnostics": "1.0.0-rc1-final",
"Microsoft.AspNet.IISPlatformHandler": "1.0.0-rc1-final",
"Microsoft.AspNet.Mvc": "6.0.0-rc1-final",
"Microsoft.AspNet.Mvc.Core": "6.0.0-rc1-final",
"Microsoft.AspNet.Mvc.TagHelpers": "6.0.0-rc1-final",
"Microsoft.AspNet.Server.Kestrel": "1.0.0-rc1-final",
"Microsoft.AspNet.StaticFiles": "1.0.0-rc1-final",
"Microsoft.AspNet.Session": "1.0.0-rc1-final",
"Microsoft.Dnx.Compilation.CSharp.Common": "1.0.0-rc1-final",
"Microsoft.VisualStudio.Web.BrowserLink.Loader": "14.0.0-rc1-final",
"System.Reflection": "4.1.0-beta-23516"
},
"dependencies": {
"GenFu": "1.1.2",
"Microsoft.AspNetCore.Diagnostics": "1.0.0",
"Microsoft.AspNetCore.Server.IISIntegration": "1.0.0",
"Microsoft.AspNetCore.Mvc": "1.0.0",
"Microsoft.AspNetCore.Mvc.TagHelpers": "1.0.0",
"Microsoft.AspNetCore.Server.Kestrel": "1.0.0",
"Microsoft.AspNetCore.StaticFiles": "1.0.0",
"Microsoft.AspNetCore.Session": "1.0.0",
"Microsoft.DotNet.Compiler.Common": "1.0.0-preview2-003121",
"Microsoft.VisualStudio.Web.BrowserLink.Loader": "14.0.0",
"System.Reflection": "4.1.0",
"Microsoft.VisualStudio.Web.CodeGeneration.Utils": "1.0.0-preview2-final",
"Microsoft.Dnx.Compilation.CSharp.Common": "1.0.0-rc1-final",
"Microsoft.Extensions.PlatformAbstractions": "1.0.0-rc1-final"
},

"commands": {
"web": "Microsoft.AspNet.Server.Kestrel"
},
"tools": {
"Microsoft.AspNetCore.Razor.Tools": {
"version": "1.0.0-preview2-final",
"imports": "portable-net45+win8+dnxcore50"
},
"Microsoft.AspNetCore.Server.IISIntegration.Tools": {
"version": "1.0.0-preview2-final",
"imports": "portable-net45+win8+dnxcore50"
}
},

"frameworks": {
"dnxcore50": { }
},
"commands": {
"web": "Microsoft.AspNet.Server.Kestrel"
},

"frameworks": {
"netcoreapp1.0": {
"imports": [
"dotnet5.6",
"portable-net45+win8"
]
}
},


"publishOptions": {
"include": [
"wwwroot",
"Views",
"appsettings.json",
"web.config"
],
"exclude": [
"node_modules",
"**.user",
"**.vspscc"
]
}

"exclude": [
"wwwroot",
"node_modules"
],
"publishExclude": [
"**.user",
"**.vspscc"
]
}
Loading

0 comments on commit 13a52c9

Please sign in to comment.