Visual studio 2015 ASP.NET核心(ASP.NET 5)运行自定义命令以启动节点http服务器

Visual studio 2015 ASP.NET核心(ASP.NET 5)运行自定义命令以启动节点http服务器,visual-studio-2015,command,asp.net-core,httpserver,Visual Studio 2015,Command,Asp.net Core,Httpserver,在AngularJS with TypeScript应用程序中,我使用ASP.NET-Core应用程序(以前称为ASP.NET 5)来提供静态文件,因此我的Startup.cs for MyProject看起来是这样的,尽管这只适用于Kestrel和IIS,因为它们查看wwwroot文件夹来提供任何内容: public class Startup { public Startup() { } public void Con

在AngularJS with TypeScript应用程序中,我使用ASP.NET-Core应用程序(以前称为ASP.NET 5)来提供静态文件,因此我的Startup.cs for MyProject看起来是这样的,尽管这只适用于Kestrel和IIS,因为它们查看
wwwroot
文件夹来提供任何内容:

public class Startup
    {
        public Startup()
        {
        }

        public void ConfigureServices(IServiceCollection services)
        {
        }

        public void Configure(IApplicationBuilder app)
        {
            app.UseIISPlatformHandler();
            app.UseDefaultFiles(); //to browse index.html or default.html
            app.UseStaticFiles();
        }

        public static void Main(string[] args) => WebApplication.Run<Startup>(args);
    }
更新:我找不到方法添加引用类的自定义命令,该类运行CMD命令(如果可能,这可能是一个好选项),以便VS2015可以在当前运行IIS Express时运行此命令。。但是作为一种解决方法,我使用Gulp和task在指定的文件夹中提供代码

gulp.task('serve', function () {
var options = {
    continueOnError: false, // default = false, true means don't emit error event 
    pipeStdout: false, // default = false, true means stdout is written to file.contents 
    customTemplatingThing: "test" // content passed to gutil.template() 
};
var reportOptions = {
    err: true, // default = true, false means don't write err 
    stderr: true, // default = true, false means don't write stderr 
    stdout: true // default = true, false means don't write stdout 
}
var port = 8080;
var url = 'localhost';
log('http-server running on port ' + port);
gulp
    .src(config.client)
    .pipe($.exec('http-server -d -o -a ' + url + ' -p ' + port, options))
    .pipe($.exec.reporter(reportOptions));
});

如果运行
dnx cargo server
,会发生什么情况?这不是您期望的结果吗?不是。它不是从命令行运行的:
dnx cargo server错误:无法加载应用程序或执行命令“http server”。可用命令:web、货运服务器。
ohhhh。。。我刚注意到你想做什么。那是行不通的。您必须使用另一个脚本自己启动http服务器。project.json中的命令是应用程序的入口点,它们必须是.net应用程序谢谢。这就是原因:)
gulp.task('serve', function () {
var options = {
    continueOnError: false, // default = false, true means don't emit error event 
    pipeStdout: false, // default = false, true means stdout is written to file.contents 
    customTemplatingThing: "test" // content passed to gutil.template() 
};
var reportOptions = {
    err: true, // default = true, false means don't write err 
    stderr: true, // default = true, false means don't write stderr 
    stdout: true // default = true, false means don't write stdout 
}
var port = 8080;
var url = 'localhost';
log('http-server running on port ' + port);
gulp
    .src(config.client)
    .pipe($.exec('http-server -d -o -a ' + url + ' -p ' + port, options))
    .pipe($.exec.reporter(reportOptions));
});