Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

The system cannot find the file specified #1663

Closed
vhmoura opened this issue Sep 20, 2018 · 18 comments
Closed

The system cannot find the file specified #1663

vhmoura opened this issue Sep 20, 2018 · 18 comments
Assignees
Labels
size:3.0 triaged The issue was evaluated by the triage team, placed on correct area, next action defined.

Comments

@vhmoura
Copy link

vhmoura commented Sep 20, 2018

Hi there,

Trying to run a post action but it seems to be failing with the message below:

Running command 'build.bat'...
The system cannot find the file specified

my template.json looks like this:

{
"author": "xxx",
"classifications": [ "Web" ],
"name": "Project",
"identity": "Project",
"shortName": "Project",
"tags": {
"language": "C#"
},
"sourceName": "Net.Project",
"preferNameDirectory" : "true",
"postActions": [{
"actionId": "3A7C4B45-1F5D-4A30-959A-51B88E82B5D2",
"args": {
"executable": "build.bat",
"args": ""
},
"manualInstructions": [{
"text": "Run 'build.bat'"
}],
"continueOnError": "true",
"description ": "setups the project by calling build.bat"
}]
}

The command I am running is like this:
dotnet new Net.Project -o SuperUperDuper

It creates the project, copy all the files to folder appropriately but it fails with the system cannot find the file.

Any clues?

Thanks in advance.

@seancpeters
Copy link
Contributor

Where is the file build.bat located? If it's at the root of your template output, it should work. If it's in a subdirectory of the template output, you'll need to give the relative path in the post action configuration. For example:

{
…
"executable": "path\to\file\build.bat",
…
}

@mlorbetske
Copy link
Contributor

I believe you need to set the executable to “cmd.exe” and the args property to “/c {the relative path to your batch file}”

@mlorbetske
Copy link
Contributor

Closing this since we haven't heard back. Please let us know if this is still an issue

@ADIX7
Copy link

ADIX7 commented Jan 28, 2019

I have the same issue. Because preferNameDirectory is true dotnet will create a folder for the project so "executable" should be ProjectName\build.bat instead of build.bat. Is there any variable I can use in the executable variable? I tried the same value as the sourceName but it does not work.

@mlorbetske
Copy link
Contributor

@ADIX7 could you post more details please? A link to the right files in a repository would be best, otherwise the contents of template.json and the file/directory structure of your template content would also work

@mlorbetske mlorbetske reopened this Feb 6, 2019
@ADIX7
Copy link

ADIX7 commented Feb 6, 2019

template.json: https://pastebin.com/Vh5a7Gu3
Directory tree: https://pastebin.com/r2EQsSgX
command: dotnet new vmtsMdm --name VMTS.Web.Tutorial_ClassDiagram --className ClassDiagram --domainName ClassDiagramWebTutorial

When preferNameDirectory is false, dotnet new will create all the content in the current directory. In my case there will be an initTemplate.sh (and an initTemplate.ps1 but lets focus to linux, same happens on both platform) file. I start it with 'Run script' (3A7C4B45-1F5D-4A30-959A-51B88E82B5D2) post action. When preferNameDirectory is false initTemplate.sh will be in the current folder.

When preferNameDirectory is true dotnet new will create a VMTS.Web.Tutorial_ClassDiagram folder (if you run the command I gave above) and the content will go there. But the run script post action will try to run initTemplate.sh instead of VMTS.Web.Tutorial_ClassDiagram/initTemplate.sh

So preferNameDirectory: true will create a folder but run script post action does not handle this.

There could be several solutions:
-Change the process's working directory to the newly created instead of the current if preferNameDirectory is true
-Give some variable what we can use in executable and/or args parameters of the run script post action

@mlorbetske
Copy link
Contributor

That's exactly the information I was looking for, thanks! We'll hopefully get to dig in to this more soon.

@ADIX7
Copy link

ADIX7 commented Feb 6, 2019

Your welcome :) Looking forward for the results.

@mlorbetske
Copy link
Contributor

Would you also be able to provide the output of dotnet new --debug:version please?

@ADIX7
Copy link

ADIX7 commented Feb 7, 2019

On Ubuntu 18.04 with dotnet 2.2.103
edit: the same on Windows 10 1809

$ dotnet new --debug:version

Permission denied to modify the '/usr/share/dotnet/sdk/NuGetFallbackFolder' folder.

Here are some options to fix this error:

  1. Re-run this command with elevated access.
  2. Disabled the first run experience by setting the environment variable DOTNET_SKIP_FIRST_TIME_EXPERIENCE to true.
  3. Copy the .NET Core SDK to a non-protected location and use it from there.

Template Instantiation Commands for .NET Core CLI

Version: 1.0.2-beta4
Commit Hash: 2b52e96

@brandonseydel
Copy link

This is happening to me as well. I have work around but they are not appealing to look at in the command window.

@kierenj
Copy link

kierenj commented Apr 25, 2019

I have the same issue. preferNameDirectory is true and I'm using:

  {
      "actionId": "3A7C4B45-1F5D-4A30-959A-51B88E82B5D2",
      "args": {
        "executable": "seed.cmd",
        "args": ""
      },
      "manualInstructions": [
        {
          "text": "Run 'seed.cmd'"
        }
      ],
      "continueOnError": true,
      "description ": "Seeds the system"
    }

Output:

Template is configured to run the following action:
Description:
Manual instructions: Run 'seed.cmd'
Actual command: seed.cmd 
Do you want to run this action (Y|N)?
Y
Running command 'seed.cmd '...
The system cannot find the file specified.

It's a real blocker at the moment, anything I can do at all?

@kolluri-rk
Copy link

kolluri-rk commented Oct 1, 2019

I have same issue. I was able to make it work on Mac with bash script, but not able to get it work on windows machine with batch file.

I tried to describe my workflow as clear as possible. please let me know how can I get this working on windows.

my use case is -

  • user provides an input swagger file (configured as symbol)
  • template output will have an empty spec folder
  • user provided input swagger file has to be copied into spec folder (using post actions)
"symbols": {
  "InputSpec": {
      "type": "parameter",
      "datatype": "string",
      "defaultValue": "",
      "replaces": "swagger-spec",
      "description": "The value of this symbol replaces 'swagger-spec' in the generated content"
    }
  },
{
      "actionId": "3A7C4B45-1F5D-4A30-959A-51B88E82B5D2",
      "description ": "copies input swagger spec by calling copy-spec.cmd",  
      "condition": "(OS == \"Windows_NT\")",
      "manualInstructions": [{ "text": "Run 'postActionScripts\\copy-spec.cmd'" }],
      "continueOnError": false,
      "args": {
        "executable": "'postActionScripts\\copy-spec.cmd",
        "args": ""
      }
    }

my template folder structure (removed other content for brevity). preferNameDirectory was set to true in template.json.

└── webapi-template
    ├── WebApi.Template.sln
    ├── postActionScripts
    │   ├── copy-spec.cmd
    │   └── copy-spec.sh
    ├── src
    │   └── WebApi.Template
    │       ├── WebApi.Template.csproj
    │       └── spec
    │       │   └── empty.dir
    └── test
    ├── WebApi.Template.IntegrationTests
    └── WebApi.Template.UnitTests

dotnet new command

dotnet new agwebapi -n ProductApi --InputSpec c:\swaggerspecs\some-swagger.json --allow-scripts yes

here is dotnet new version

dotnet new --debug:version
Template Instantiation Commands for .NET Core CLI

 Version:     1.0.2-beta4
 Commit Hash: 2b52e96b5737d86c215e0d80483d48c4b107c2a8

@dannycarrera
Copy link

I'm running into this issue as well.

@donJoseLuis
Copy link
Contributor

  1. Adding item to specific project corresponding to a targeted delivery area
  2. Once this has been done for the entire backlog, the next steps will be to prioritize within each project & output a delivery roadmap.
  3. At that point, the issues will be assigned to a corresponding milestone
  4. The team will then begin to deliver against the road map, contributions always welcome

@donJoseLuis donJoseLuis added needsprioritization triaged The issue was evaluated by the triage team, placed on correct area, next action defined. size:5.0 and removed needs-prioritization labels Mar 19, 2020
@MaxCrank
Copy link

Not sure if it's the same bug, because it's happening only on Windows. I have a postprocessing folder which contains several text files.

The following post-action code to remove this folder doesn't work, throwing error that it wasn't found:

{
    "actionId": "3A7C4B45-1F5D-4A30-959A-51B88E82B5D2",
    "condition": "(OS == \"win\")",
    "args": {
      "executable": "rmdir",
      "args": "/s /q postprocessing"
    },
    "continueOnError": false
  }

I've tried "postprocessing", ./postprocessing, .\\postprocessing etc., no luck. Absolute path isn't an option obviously. del command behaves exactly the same way. Still, if I copy-paste it to cmd and run manually, everything is OK.

At the same time, the Powershell workaround below does work.

{
    "actionId": "3A7C4B45-1F5D-4A30-959A-51B88E82B5D2",
    "condition": "(OS == \"win\")",
    "args": {
      "executable": "powershell",
      "args": "-command Remove-Item -Recurse -Force \"postprocessing\""
    },
    "continueOnError": false
  }

For Linux I use rm and it works absolutely fine, too.

@AR-May AR-May self-assigned this Sep 8, 2020
@AR-May
Copy link
Member

AR-May commented Sep 28, 2020

Hello @MaxCrank, yes, it seems like you had not the same bug as others. My understanding at the moment that rmdir is not an executable, but just a command, so it can not be used there.

@AR-May
Copy link
Member

AR-May commented Oct 5, 2020

Fixed. Implemented search logic: first, search for the executable file in the template base folder, then, if no file has been found, the executable should be searched in the directories from PATH.

@AR-May AR-May closed this as completed Oct 5, 2020
AR-May added a commit to AR-May/templating that referenced this issue Oct 14, 2020
AR-May added a commit that referenced this issue Oct 15, 2020
vlada-shubina pushed a commit to vlada-shubina/templating that referenced this issue Dec 18, 2020
vlada-shubina pushed a commit to vlada-shubina/templating that referenced this issue Dec 18, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
size:3.0 triaged The issue was evaluated by the triage team, placed on correct area, next action defined.
Projects
None yet
Development

No branches or pull requests