-
Notifications
You must be signed in to change notification settings - Fork 362
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
Reduce publish slug size #20
base: master
Are you sure you want to change the base?
Conversation
Thank you for working on this! Slug size has been an issue for me as well. |
@@ -41,12 +41,12 @@ dotnet --info | |||
PROJECT_FILE=$(x=$(dirname $(find ${BUILD_DIR} -maxdepth 5 -iname Startup.cs | head -1)); while [[ "$x" =~ $BUILD_DIR ]] ; do find "$x" -maxdepth 1 -name *.csproj; x=`dirname "$x"`; done) | |||
PROJECT_NAME=$(basename ${PROJECT_FILE%.*}) | |||
|
|||
echo "restore ${PROJECT_FILE}" | |||
dotnet restore $PROJECT_FILE --runtime linux-x64 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Removed dotnet restore here because dotnet restore is now an implicit command, dotnet publish internally calls dotnet restore, no needs explicit call anymore.
Reference: dotnet/announcements#23
|
||
cat << EOT >> ${BUILD_DIR}/Procfile | ||
web: cd \$HOME/heroku_output && ASPNETCORE_URLS='http://+:\$PORT' dotnet "./${PROJECT_NAME}.dll" --server.urls http://+:\$PORT | ||
web: cd \$HOME/heroku_output && chmod +x ${PROJECT_NAME} && ASPNETCORE_URLS='http://+:\$PORT' ./${PROJECT_NAME} --server.urls http://+:\$PORT |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Add chmod +x here because the executable generated from dotnet publish does not have "x" permission
Reference: dotnet/sdk#1331
Hi @lppkarl Many thanks for your contribution! I'll review it. |
@lppkarl I've tried this but it still outputs a .dll (which can't be executed) - is there some additional config i need to change in my project? |
@chrisanderton Maybe you have targeted a wrong framework? The publish command generates executable (with no extension) only when you're targeting netcoreapp instead of netstandard |
hmm @lppkarl i'm targeting netcoreapp1.1 - but tbh i'm not so strong on dotnet - does this only work with 2.0? |
@chrisanderton As I see it, --self-contained tag only works for netcoreapp2.0, you may migrate your project from 1.1 to 2.0. See https://docs.microsoft.com/en-us/aspnet/core/migration/1x-to-2x/ 😄 |
@lppkarl , I'm currently using your pull request link for buildpack and it reduces my heroku app slug size from 430MB to 40MB. My app is .net core app 2.0. Great works! |
Hi @lppkarl Would be great to do this feature optional Also I've added env var |
@jincod ya, I could help implement it. I'm interested in how |
Hi @lppkarl Thanka a lot! Ping me if you have any questions.
|
@jincod As I am also having an issue of large slug size similar to #19 , I have implemented logic to reduce the slug size when publish to heroku. In my case, the slug size is reduced from 470MB to 81MB.
It is done by publishing a self-contained dotnet app instead of embedding the whole dotnet core runtime into the slug, hence the great reduction in size. See if you could accept this PR, thanks 😄