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

Fix for the sourceFolder option when using the aspnet5 generator. #3160

Closed
wants to merge 1 commit into from

Conversation

debben
Copy link

@debben debben commented Jun 17, 2016

Fixes #3137

The issue was the redefinition of the protected string sourceFolder in AspNet5ServerCodegen.java. This hides the previous definition of sourceFolder AbstractCSharpCodegen.java. Moving the initialization of sourceFolder to the constructor of the AspNet5ServerCodegen class seems to resolve the issue for me.

@jimschubert
Copy link
Contributor

This should include updates for build.sh and global.json, which still reference the src default after this change:

$ cat global.json
{
  "projects": [ "src", "." ],
  "sdk": {
    "version": "1.0.0-rc1-final",
    "runtime": "coreclr",
    "architecture": "x64"
  }
}
$ cat build.sh
#!/usr/bin/env bash

if ! type dnvm > /dev/null 2>&1; then
    source /usr/local/lib/dnx/bin/dnvm.sh
fi

if ! type dnu > /dev/null 2>&1 || [ -z "$SKIP_DNX_INSTALL" ]; then
    dnvm install latest -runtime coreclr -alias default
    dnvm install default -runtime mono -alias default
else
    dnvm use default -runtime mono
fi

dnu restore src/IO.Swagger/ && \
    dnu build src/IO.Swagger/ && \
    dnu pack src/IO.Swagger/ --out artifacts && \
    echo "Now, run the following to start the project: dnx --project src/IO.Swagger/project.json web"

Originally, the intention of forcing src/ProjectName for the output here was to follow community standards (see, for example, Entity Framework, Scaffolding, Ahoy).

If I remember correctly, at the time I wrote the generator people were having trouble trying to deviate from the standard. Running your changes locally (and making the modifications to the two files mentioned above), it seems to be the case that changing the source folder is still unsupported:

$ ./build.sh
Default stable feed (https://www.nuget.org/api/v2) is being overridden by the value of the DNX_FEED variable (https://www.nuget.org/api/v2).
Determining latest version
Latest version is 1.0.0-rc1-update2
Downloading dnx-coreclr-darwin-x64.1.0.0-rc1-update2 from https://www.nuget.org/api/v2
Download: https://www.nuget.org/api/v2/package/dnx-coreclr-darwin-x64/1.0.0-rc1-update2
######################################################################## 100.0%
Installing to /Users/jim/.dnx/runtimes/dnx-coreclr-darwin-x64.1.0.0-rc1-update2
Adding /Users/jim/.dnx/runtimes/dnx-coreclr-darwin-x64.1.0.0-rc1-update2/bin to process PATH


Updating alias 'default' to 'dnx-coreclr-darwin-x64.1.0.0-rc1-update2'
Default stable feed (https://www.nuget.org/api/v2) is being overridden by the value of the DNX_FEED variable (https://www.nuget.org/api/v2).
Downloading dnx-mono.1.0.0-rc1-update2 from https://www.nuget.org/api/v2
Download: https://www.nuget.org/api/v2/package/dnx-mono/1.0.0-rc1-update2
######################################################################## 100.0%
Installing to /Users/jim/.dnx/runtimes/dnx-mono.1.0.0-rc1-update2
Adding /Users/jim/.dnx/runtimes/dnx-mono.1.0.0-rc1-update2/bin to process PATH
Updating alias 'default' to 'dnx-mono.1.0.0-rc1-update2'
Microsoft .NET Development Utility Mono-x64-1.0.0-rc1-16609

The given root /Volumes/Extra/projects/swagger-codegen/samples/server/petstore/aspnet5/mysrc/IO.Swagger/ is invalid.

Errors in /Volumes/Extra/projects/swagger-codegen/samples/server/petstore/aspnet5/mysrc/IO.Swagger/
    The given root /Volumes/Extra/projects/swagger-codegen/samples/server/petstore/aspnet5/mysrc/IO.Swagger/ is invalid.

I reset the sample to the forced src output, and it works as expected:

jim at macbert in ~/projects/swagger-codegen/samples/server/petstore/aspnet5 on debben-sourceFolder-bugfix* b3a4a89
$ ./build.sh
Default stable feed (https://www.nuget.org/api/v2) is being overridden by the value of the DNX_FEED variable (https://www.nuget.org/api/v2).
Determining latest version
Latest version is 1.0.0-rc1-update2
dnx-coreclr-darwin-x64.1.0.0-rc1-update2 already installed in /Users/jim/.dnx
Adding /Users/jim/.dnx/runtimes/dnx-coreclr-darwin-x64.1.0.0-rc1-update2/bin to process PATH
Updating alias 'default' to 'dnx-coreclr-darwin-x64.1.0.0-rc1-update2'
Default stable feed (https://www.nuget.org/api/v2) is being overridden by the value of the DNX_FEED variable (https://www.nuget.org/api/v2).
dnx-mono.1.0.0-rc1-update2 already installed in /Users/jim/.dnx
Adding /Users/jim/.dnx/runtimes/dnx-mono.1.0.0-rc1-update2/bin to process PATH
Updating alias 'default' to 'dnx-mono.1.0.0-rc1-update2'
Microsoft .NET Development Utility Mono-x64-1.0.0-rc1-16609

  GET https://nuget.org/api/v2/
  OK https://nuget.org/api/v2/ 833ms
  GET https://www.myget.org/F/aspnetvnext/api/v2/
  OK https://www.myget.org/F/aspnetvnext/api/v2/ 617ms
Restoring packages for /Volumes/Extra/projects/swagger-codegen/samples/server/petstore/aspnet5/src/IO.Swagger/project.json
…

I'd imagine supporting this may make sense if you're only planning on working on the web application, but I don't think the support will be there for the multi-project build support inherent to the template prior to the change. Do you have a use case where changing the source folder name is required, so I can test it out?

@wing328
Copy link
Contributor

wing328 commented Jul 7, 2016

@debben can you please share the use case with us?

@wing328 wing328 modified the milestones: Future, v2.2.0 Jul 7, 2016
@wing328
Copy link
Contributor

wing328 commented Dec 20, 2016

@debben thanks for the PR but we've to close this as there's no update from you.

@wing328 wing328 closed this Dec 20, 2016
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

aspnet5 generator ignores sourceFolder option
4 participants