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

minimalapi -outdir inconsistent behaviour #1884

Closed
mrward opened this issue May 5, 2022 · 2 comments
Closed

minimalapi -outdir inconsistent behaviour #1884

mrward opened this issue May 5, 2022 · 2 comments

Comments

@mrward
Copy link

mrward commented May 5, 2022

File a bug

The -outdir argument for the minimalapi is inconsistent with other scaffolders. Other scaffolders support a full path but minimalapi does not.

Specifying a full path ends up creating a file with the filename which is the full path.

Relative paths such as "./" end up creating this as part of the filename.

This works:

dotnet-aspnet-codegenerator minimalapi -m FooModel -e EndPointsClass -outDir "Foo" --endpointsNamespace "TestNS"

These do not:

dotnet-aspnet-codegenerator minimalapi -m FooModel -e EndPointsClass -outDir "./" --endpointsNamespace "TestNS"
dotnet-aspnet-codegenerator minimalapi -m FooModel -e EndPointsClass -outDir "" --endpointsNamespace "TestNS"
dotnet-aspnet-codegenerator minimalapi -m FooModel -e EndPointsClass -outDir "/Full/Path/To/OutDir" --endpointsNamespace "TestNS"

VS Mac currently uses the full path for -outDir to other scaffolders.

Workaround here is to only use a relative path and remove the -outDir argument if the project directory is being used.

Include provider and version information

Microsoft.VisualStudio.Web.CodeGeneration.Design version: 6.0.3
Target framework: .NET 6.0.201
Operating system: macOS
IDE: command line

@mrward
Copy link
Author

mrward commented May 5, 2022

The problem seems to be the minimal api scaffolder is using Path.Join not Path.Combine. This does not handle paths in the same way.

https://github.com/dotnet/Scaffolding/blob/main/src/Scaffolding/VS.Web.CG.Mvc/Minimal%20Api/MinimalApiGenerator.cs#L132

string path1 = "/Users/test/foo";
string path2 = "/Users/test/foo/bar";

string result = Path.Combine(path1, path2);
Console.WriteLine (result);

string result2 = Path.Join(path1, path2);
Console.WriteLine (result2);

Output:

/Users/test/foo/bar
/Users/test/foo/Users/test/foo/bar

@deepchoudhery
Copy link
Member

@mrward Hey, should be fixed in .NET 7 scenarios. Apologies didn't get serviced for .NET 6, will get fixed next month.

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

No branches or pull requests

3 participants