Skip to content
This repository was archived by the owner on Dec 18, 2017. It is now read-only.

Enabling implicit appbase (dnx . run -> dnx run) #2263

Merged
merged 2 commits into from
Jul 22, 2015
Merged

Conversation

moozzyk
Copy link
Contributor

@moozzyk moozzyk commented Jul 15, 2015

Before providing appbase folder was necessary. Now if the appbase folder is not provided we will use the current folder (.) automatically.

Note that there might be an ambiguity between a folder and command which is resolved by checking if a folder with the provided name physically exists and if it does the parameter is treated as folder path otherwise it is treated as a command.

Fixes #1403

@moozzyk
Copy link
Contributor Author

moozzyk commented Jul 15, 2015

/cc @anurse @davidfowl @ChengTian

bool DirectoryExists(const char* path)
{
struct stat s;
return stat(path, &s) == 0 && S_ISDIR(s.st_mode);
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Need to verify this manually.

@davidfowl
Copy link
Member

Where are the mono changes?

@moozzyk
Copy link
Contributor Author

moozzyk commented Jul 15, 2015

Mono will be done separately. This is already too big...

@analogrelay
Copy link
Contributor

I thought we weren't going to do the folder check and only support filenames (replacing the command, effectively). Selecting a different folder would only be supported by dnx -p /path/to/project run

}

bool LastPathSeparatorIndex(LPCTSTR pszPath, size_t* pIndex)
int split_path(const dnx::char_t* path)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Not a fan of this function name

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Couldn't come up with a better name but if you have a proposal let me know... I am also still considering changing it to return two std::strings - directory and filename - these buffer operations are so fragile.

@davidfowl
Copy link
Member

I thought we weren't going to do the folder check and only support filenames (replacing the command, effectively). Selecting a different folder would only be supported by dnx -p /path/to/project run

I thought that was the plan? VS uses the full --appbase expansion. The only thing we need to support is .

@moozzyk
Copy link
Contributor Author

moozzyk commented Jul 16, 2015

Even better - I did not like going to the disk to check if the folder exists.

@moozzyk
Copy link
Contributor Author

moozzyk commented Jul 16, 2015

Updated the PR so that we no longer check if an argument is a folder except for . when it always is treated as a folder.

@moozzyk
Copy link
Contributor Author

moozzyk commented Jul 16, 2015

(Travis fails because the fix for Mono is separate - #2269 - I will push them together or can squash once reviewed)

@moozzyk
Copy link
Contributor Author

moozzyk commented Jul 17, 2015

ppszExpandedArgv[i] = new TCHAR[MAX_PATH];
// "dnx /path/App.dll arg1" --> "dnx --appbase /path/ /path/App.dll arg1"
// "dnx /path/App.exe arg1" --> "dnx --appbase /path/ /path/App.exe arg1"
// "dnx App.exe arg1" --> "dnx --appbase --appbase . App.exe arg1"
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Only 1 --appbase right?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yeah. I will fix this.

@analogrelay
Copy link
Contributor

:shipit: - I don't know what --project is, but whatever it is, it sounds new... I'd rather just get this in so we can start seeing what this does.

@davidfowl
Copy link
Member

@anurse Wasn't that part of the suggestion? -p to replace dnx {path} {command}

moozzyk added 2 commits July 22, 2015 07:07
Before providing appbase folder was necessary. Now we don't expect a folder anymore but assume that the current folder is the appbase folder. The only exception is where for backwards compatibility we continue to recognize `.` (so `dnx . run` continues to work). If the user really wants to provide a folder that is not the current folder they need to use the --appbase parameter.

Fixes #1403
The user no longer has to provide folder (or `.`) when running dnx commands.

Note that there might be an ambiguity between a folder and command which is resolved by checking if a folder with the provided name physically exists and if it does the parameter is treated as folder path otherwise it is treated as a command.

Fixes #1403
@moozzyk moozzyk merged commit d901b0a into dev Jul 22, 2015
@analogrelay
Copy link
Contributor

Yes but -p was just a short form for --appbase, not a new argument.

@moozzyk
Copy link
Contributor Author

moozzyk commented Jul 22, 2015

@anurse Can't be. If --appbase is provided we don't do any expansion (and never have) so the user would have to provide the host. We will create a new -p argument that will expand to --appbase {path} Microsoft.Framework.ApplicationHost

@moozzyk moozzyk deleted the pawelka/appbase branch July 22, 2015 16:52
@analogrelay
Copy link
Contributor

My original proposal was to always use Microsoft.Framework.ApplicationHost unless the first argument is a dll or exe. So dnx --appbase Foo would expand to dnx --appbase Foo Microsoft.Framework.ApplicationHost.dll. If we want to do it as a different argument, that's OK with me. I just don't see a use case for dnx --appbase Foo SomethingThatIsNotADll without using AppHost...

@moozzyk
Copy link
Contributor Author

moozzyk commented Jul 22, 2015

If we always expanded as you propose how would you do dnx --appbase AppFolder MyHost.dll run ?

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

Successfully merging this pull request may close these issues.

dnx requiring "run" can be improved a bit
6 participants