Permalink
Browse files

Initial porting work to .NET and ASP.NET Core, but still getting buil…

…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 13a52c97c2ae97f147fd0546c3e1d7c53310b7f8
View
@@ -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"
+ }
}
@@ -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;
@@ -78,7 +80,7 @@ public IActionResult Download()
if (randomObjectsJson == null)
{
- return HttpBadRequest();
+ return BadRequest();
}
var randomObjectsJsonAsBytes = new UTF8Encoding().GetBytes(randomObjectsJson);
@@ -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>
@@ -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
{
@@ -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;
@@ -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;
@@ -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));
View
@@ -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
@@ -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);
@@ -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();
@@ -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
+ }
+ }
}
View
@@ -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"
- ]
}
Oops, something went wrong.

0 comments on commit 13a52c9

Please sign in to comment.