Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/csharp/267.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
C# 无法使用cmd.exe在iis托管的asp.net web应用程序中执行命令ng build_C#_Iis_Angular Cli - Fatal编程技术网

C# 无法使用cmd.exe在iis托管的asp.net web应用程序中执行命令ng build

C# 无法使用cmd.exe在iis托管的asp.net web应用程序中执行命令ng build,c#,iis,angular-cli,C#,Iis,Angular Cli,我想使用c#代码执行ng build来构建我的angular项目。我在IIS上托管了c#应用程序。当我执行代码时,我得到错误: ng'未被识别为内部或外部命令,\r\n无法运行的程序或批处理文件。\r\n 我已经创建了另一个没有在IIS上托管的应用程序,我正在使用visual studio在本地执行该应用程序。在相同的代码中,工作属性是相同的。我无法解决iis的问题。我的代码如下 private void buildAngular() { try

我想使用c#代码执行ng build来构建我的angular项目。我在IIS上托管了c#应用程序。当我执行代码时,我得到错误:

ng'未被识别为内部或外部命令,\r\n无法运行的程序或批处理文件。\r\n

我已经创建了另一个没有在IIS上托管的应用程序,我正在使用visual studio在本地执行该应用程序。在相同的代码中,工作属性是相同的。我无法解决iis的问题。我的代码如下

private void buildAngular()
        {
            try
            {

                Process p = new Process();
                p.EnableRaisingEvents = true;
                p.StartInfo.FileName = "cmd.exe";
                p.StartInfo.WorkingDirectory = @"D:\AngularToBuild\AngularProject";
                p.StartInfo.UseShellExecute = false;
                //p.StartInfo.Arguments = @"/c echo off > fff1.txt";
                p.StartInfo.Arguments = @"/c ng build";
                p.StartInfo.RedirectStandardOutput = true;
                p.StartInfo.RedirectStandardError = true;

                p.Start();

                p.Exited += new EventHandler(myProcess_Exited);

                var err = p.StandardError.ReadToEnd();
                var msg = p.StandardOutput.ReadToEnd();

                Console.WriteLine("error", msg, err);
            }
            catch (Exception ex)
            {
                Console.WriteLine("error");
            }

        }
        private void myProcess_Exited(object sender, System.EventArgs e)
        {
            Console.WriteLine("Exit time:    {0}\r\n" +
                "Exit code:    {1}\r\nElapsed time: {2}");
        }

ng.cmd
位于
C:\Users\\AppData\Roaming\npm
中,但默认应用程序池标识没有访问该文件夹的权限


向应用程序池标识授予NTFS读取权限,并确保文件夹包含在
PATH
环境系统变量中

DefaultAppPool的默认应用程序池标识为
IIS APPPOOL\DefaultAppPool
。。您需要授予此帐户的权限

  • 打开Windows资源管理器
  • 转到
    C:\Users\\AppData\Roaming
  • 右键单击
    npm
  • 选择
    属性
  • 选择
    Security
    选项卡
  • 单击编辑按钮
  • 单击
    添加
    按钮
  • 在文本框中输入
    IIS APPPOOL\DefaultAppPool
  • 单击
    Ok
    按钮
  • 确保检查了
    读取和执行
    列表文件夹和内容
    读取
    权限
  • 单击
    Ok
  • 单击
    Ok

  • 哪个是应用程序池标识?应用程序池标识:DefaultAppPool这是应用程序池,而不是应用程序池标识。应用程序池标识是它运行的帐户。哦,对不起。在ApplicationPoolIdentity中,在DefaultAppPool下选择“ApplicationPoolIdentity”。将DefaultAppPool更改为LocalSystem有效。现在它正在工作。将NTFS读取权限授予应用程序池标识。如何做到这一点??将DefaultAppPool更改为LocalSystem有效。现在它正在工作。更新的答案为您提供添加NTFS权限的说明。LocalSystem的帐户容量过大。它可以在你的系统上做任何事情。如果我建议您将帐户更改为系统帐户,我将收到很多向下的votesHi感谢您的详细解释。我试过了,并按照你的建议给予了必要的许可。但这次我又犯了新的错误。fs.js:1690 binding.lstat(baseLong);^错误:EPERM:不允许操作,lstat'C:\Users\username'at Object.realpathSync(fs.js:1690:15)at toRealPath(module.js:170:13)at Function.module.\u findPath(module.js:219:22)at Function.module.\u resolveFilename(module.js:541:25)at Function.module.\u load(module.js:470:25)at Function.module.runMain(模块js:690:10)