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

Producing a working SpaServices NuGet package #261

Closed
mattwcole opened this issue Aug 14, 2016 · 2 comments
Closed

Producing a working SpaServices NuGet package #261

mattwcole opened this issue Aug 14, 2016 · 2 comments

Comments

@mattwcole
Copy link

I am unable to create a working NuGet package for SpaServices locally on my Windows machine (tried dev and master branches). Following a dotnet restore, I am running the following from both NodeServices and SpaServices directories.

dotnet pack -c Release --version-suffix custom-1 -o /c/dev/nuget

In my project, SpaServices will successfully upgrade from the official package to my custom version (with as yet unchanged source), however the next dotnet run fails at UseWebpackDevMiddleware() with the exception below. I've checked my cache in ~/.nuget and everything appears to be in order with the package.

Unhandled Exception: System.Reflection.TargetInvocationException: Exception has been thrown by the target of an invocation. ---> System.AggregateException: One or more errors occurred. (Call to Node module failed with error: Error: Cannot find module 'C:\Users\Matt\AppData\Local\Temp\tmp2C5.tmp'
    at Function.Module._resolveFilename (module.js:440:15)
    at Function.Module._load (module.js:388:25)
    at Module.require (module.js:468:17)
    at require (internal/module.js:20:19)
    at C:\Users\Matt\AppData\Local\Temp\tmp382.tmp:104:34
    at IncomingMessage.<anonymous> (C:\Users\Matt\AppData\Local\Temp\tmp382.tmp:128:35)
    at emitNone (events.js:86:13)
    at IncomingMessage.emit (events.js:185:7)
    at endReadableNT (_stream_readable.js:973:12)
    at _combinedTickCallback (internal/process/next_tick.js:74:11)) ---> System.Exception: Call to Node module failed with error: Error: Cannot find module 'C:\Users\Matt\AppData\Local\Temp\tmp2C5.tmp'
    at Function.Module._resolveFilename (module.js:440:15)
    at Function.Module._load (module.js:388:25)
    at Module.require (module.js:468:17)
    at require (internal/module.js:20:19)
    at C:\Users\Matt\AppData\Local\Temp\tmp382.tmp:104:34
    at IncomingMessage.<anonymous> (C:\Users\Matt\AppData\Local\Temp\tmp382.tmp:128:35)
    at emitNone (events.js:86:13)
    at IncomingMessage.emit (events.js:185:7)
    at endReadableNT (_stream_readable.js:973:12)
    at _combinedTickCallback (internal/process/next_tick.js:74:11)
   at Microsoft.AspNetCore.NodeServices.HostingModels.HttpNodeInstance.<InvokeExportAsync>d__7`1.MoveNext()
--- End of stack trace from previous location where exception was thrown ---
   at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task)
   at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
   at Microsoft.AspNetCore.NodeServices.HostingModels.OutOfProcessNodeInstance.<InvokeExportAsync>d__12`1.MoveNext()

--- End of stack trace from previous location where exception was thrown ---
   at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task)
   at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
   at Microsoft.AspNetCore.NodeServices.NodeServicesImpl.<InvokeExportWithPossibleRetryAsync>d__9`1.MoveNext()
   --- End of inner exception stack trace ---
   at System.Threading.Tasks.Task.ThrowIfExceptional(Boolean includeTaskCanceledExceptions)
   at System.Threading.Tasks.Task`1.GetResultCore(Boolean waitCompletionNotification)
   at Microsoft.AspNetCore.Builder.WebpackDevMiddleware.UseWebpackDevMiddleware(IApplicationBuilder appBuilder, WebpackDevMiddlewareOptions options)
   at Trainline.ContactCentre.Host.Startup.Configure(IApplicationBuilder app, IHostingEnvironment env)
   --- End of inner exception stack trace ---
   at System.RuntimeMethodHandle.InvokeMethod(Object target, Object[] arguments, Signature sig, Boolean constructor)

   at System.Reflection.RuntimeMethodInfo.UnsafeInvokeInternal(Object obj, Object[] parameters, Object[] arguments)
   at System.Reflection.RuntimeMethodInfo.Invoke(Object obj, BindingFlags invokeAttr, Binder binder, Object[] parameters, CultureInfo culture)
   at Microsoft.AspNetCore.Hosting.Internal.ConfigureBuilder.Invoke(Object instance, IApplicationBuilder builder)
   at Microsoft.AspNetCore.Hosting.Internal.WebHost.BuildApplication()
   at Microsoft.AspNetCore.Hosting.WebHostBuilder.Build()
   at Trainline.ContactCentre.Host.Program.Main(String[] args)

From Startup.cs:

app.UseWebpackDevMiddleware(new WebpackDevMiddlewareOptions
{
    HotModuleReplacement = true,
    ReactHotModuleReplacement = true
});

My packages.json:

{
  "version": "0.1.0",
  "buildOptions": {
    "debugType": "portable",
    "emitEntryPoint": true,
    "preserveCompilationContext": true
  },
  "dependencies": {
    "Microsoft.AspNetCore.Diagnostics": "1.0.0",
    "Microsoft.AspNetCore.Mvc": "1.0.0",
    "Microsoft.AspNetCore.Server.Kestrel": "1.0.0",
    "Microsoft.AspNetCore.SpaServices": "1.0.0-custom-1",
    "Microsoft.AspNetCore.StaticFiles": "1.0.0",
    "Microsoft.Extensions.Configuration.CommandLine": "1.0.0",
    "Microsoft.Extensions.Configuration.EnvironmentVariables": "1.0.0"
  },
  "frameworks": {
    "netcoreapp1.0": {
      "dependencies": {
        "Microsoft.NETCore.App": {
          "type": "platform",
          "version": "1.0.0"
        }
      },
      "imports": "dnxcore50"
    }
  }
}
@SteveSandersonMS
Copy link
Member

I'm not sure what technique you're using to get your project to reference your custom-built SpaServices package, but my guess is that something must be set up incorrectly with that.

If you want to run with a custom-modified dependency, I'd suggest this technique to make it build the dependency from source: http://stackoverflow.com/a/29260539. This way there's no need to hack around with your ~/.nuget directory. This is how the JavaScriptServices repo itself it set up so that when editing samples (etc) it loads NodeServices/SpaServices/etc directly from source and there's no need to build them manually.

If you then want to distribute your custom SpaServices package, you can of course give it some distinct name and publish to any NuGet service.

@mattwcole
Copy link
Author

Thanks for the help, looks like that will do the trick!

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants