jincod / dotnetcore-buildpack

Heroku .NET Core Buildpack
MIT License
751 stars 366 forks source link

App not able to access the Content folder on deployed environment #155

Closed pkaiche closed 2 years ago

pkaiche commented 2 years ago

Hello,

I have deployed my app to Heroku and using https://github.com/jincod/dotnetcore-buildpack for the build.

I am getting the below exception in my app in one of the functionalities.

image

When checking the folder structure on Heroku it came to my notice that the Content folder is not present in my heroku_output folder.

Below is the code block getting the exception:

image

Below is the deployed app file structure:

image

How can i use the API assets used by my application inside a Content folder? Any way we can get this working?

@jincod Any help is deeply appreciated!

jincod commented 2 years ago

Hello @pkaiche

Make sure you included Content folder like this https://github.com/jincod/AspNetCoreDemoApp/blob/712a969bf72525f987f1df7d0d9f563eced725df/src/AspNetCoreDemoApp/AspNetCoreDemoApp.csproj#L7-L9

pkaiche commented 2 years ago

@jincod I tried the above solution and the new build has the same exception. Also, I checked the file structure inside heroku_output folder and it doesn't contain Content folder inside it. Below is my .csproj file:

image

jincod commented 2 years ago

@pkaiche have you tried this solution https://stackoverflow.com/a/51544654?

pkaiche commented 2 years ago

@jincod I have tried the above approach. The files are not copied to the heroku_output folder in the deployed environment. I tried the Content Update approach too as I am using Microsoft.NET.Sdk.Web.

Also, I have tried the approach of Copy mentioned in https://stackoverflow.com/a/44378406/8680456. It is not working too.

jincod commented 2 years ago
  1. Does it work locally? Have you tried do dotnet publish -o build?
  2. Could you please show ls /app/heroku_output?
pkaiche commented 2 years ago

Yes, It works locally.

~ $ ls /app/heroku_output
BouncyCastle.Crypto.dll                                         System.Data.dll
CloudinaryDotNet.dll                                            System.Diagnostics.Contracts.dll
HMOS.API                                                        System.Diagnostics.Debug.dll
HMOS.API.deps.json                                              System.Diagnostics.DiagnosticSource.dll
HMOS.API.dll                                                    System.Diagnostics.EventLog.dll
HMOS.API.pdb                                                    System.Diagnostics.FileVersionInfo.dll
HMOS.API.runtimeconfig.json                                     System.Diagnostics.Process.dll
HtmlAgilityPack.dll                                             System.Diagnostics.StackTrace.dll
MailKit.dll                                                     System.Diagnostics.TextWriterTraceListener.dll
Microsoft.AspNetCore.Antiforgery.dll                            System.Diagnostics.Tools.dll
Microsoft.AspNetCore.Authentication.Abstractions.dll            System.Diagnostics.TraceSource.dll
Microsoft.AspNetCore.Authentication.Cookies.dll                 System.Diagnostics.Tracing.dll
Microsoft.AspNetCore.Authentication.Core.dll                    System.Drawing.Common.dll
Microsoft.AspNetCore.Authentication.JwtBearer.dll               System.Drawing.Primitives.dll
Microsoft.AspNetCore.Authentication.OAuth.dll                   System.Drawing.dll
Microsoft.AspNetCore.Authentication.dll                         System.Dynamic.Runtime.dll
Microsoft.AspNetCore.Authorization.Policy.dll                   System.Globalization.Calendars.dll
Microsoft.AspNetCore.Authorization.dll                          System.Globalization.Extensions.dll
Microsoft.AspNetCore.Components.Authorization.dll               System.Globalization.Native.so
Microsoft.AspNetCore.Components.Forms.dll                       System.Globalization.dll
Microsoft.AspNetCore.Components.Server.dll                      System.IO.Compression.Brotli.dll
Microsoft.AspNetCore.Components.Web.dll                         System.IO.Compression.FileSystem.dll
Microsoft.AspNetCore.Components.dll                             System.IO.Compression.Native.a
Microsoft.AspNetCore.Connections.Abstractions.dll               System.IO.Compression.Native.so
Microsoft.AspNetCore.CookiePolicy.dll                           System.IO.Compression.ZipFile.dll
Microsoft.AspNetCore.Cors.dll                                   System.IO.Compression.dll
Microsoft.AspNetCore.Cryptography.Internal.dll                  System.IO.FileSystem.AccessControl.dll
Microsoft.AspNetCore.Cryptography.KeyDerivation.dll             System.IO.FileSystem.DriveInfo.dll
Microsoft.AspNetCore.DataProtection.Abstractions.dll            System.IO.FileSystem.Primitives.dll
Microsoft.AspNetCore.DataProtection.Extensions.dll              System.IO.FileSystem.Watcher.dll
Microsoft.AspNetCore.DataProtection.dll                         System.IO.FileSystem.dll
Microsoft.AspNetCore.Diagnostics.Abstractions.dll               System.IO.IsolatedStorage.dll
Microsoft.AspNetCore.Diagnostics.HealthChecks.dll               System.IO.MemoryMappedFiles.dll
Microsoft.AspNetCore.Diagnostics.dll                            System.IO.Pipelines.dll
Microsoft.AspNetCore.HostFiltering.dll                          System.IO.Pipes.AccessControl.dll
Microsoft.AspNetCore.Hosting.Abstractions.dll                   System.IO.Pipes.dll
Microsoft.AspNetCore.Hosting.Server.Abstractions.dll            System.IO.UnmanagedMemoryStream.dll
Microsoft.AspNetCore.Hosting.dll                                System.IO.dll
Microsoft.AspNetCore.Html.Abstractions.dll                      System.IdentityModel.Tokens.Jwt.dll
Microsoft.AspNetCore.Http.Abstractions.dll                      System.Linq.Expressions.dll
Microsoft.AspNetCore.Http.Connections.Common.dll                System.Linq.Parallel.dll
Microsoft.AspNetCore.Http.Connections.dll                       System.Linq.Queryable.dll
Microsoft.AspNetCore.Http.Extensions.dll                        System.Linq.dll
Microsoft.AspNetCore.Http.Features.dll                          System.Memory.dll
Microsoft.AspNetCore.Http.dll                                   System.Native.a
Microsoft.AspNetCore.HttpOverrides.dll                          System.Native.so
Microsoft.AspNetCore.HttpsPolicy.dll                            System.Net.Http.Native.a
Microsoft.AspNetCore.Identity.dll                               System.Net.Http.Native.so
Microsoft.AspNetCore.JsonPatch.dll                              System.Net.Http.dll
Microsoft.AspNetCore.Localization.Routing.dll                   System.Net.HttpListener.dll
Microsoft.AspNetCore.Localization.dll                           System.Net.Mail.dll
Microsoft.AspNetCore.Metadata.dll                               System.Net.NameResolution.dll
Microsoft.AspNetCore.Mvc.Abstractions.dll                       System.Net.NetworkInformation.dll
Microsoft.AspNetCore.Mvc.ApiExplorer.dll                        System.Net.Ping.dll
Microsoft.AspNetCore.Mvc.Core.dll                               System.Net.Primitives.dll
Microsoft.AspNetCore.Mvc.Cors.dll                               System.Net.Requests.dll
Microsoft.AspNetCore.Mvc.DataAnnotations.dll                    System.Net.Security.Native.a
Microsoft.AspNetCore.Mvc.Formatters.Json.dll                    System.Net.Security.Native.so
Microsoft.AspNetCore.Mvc.Formatters.Xml.dll                     System.Net.Security.dll
Microsoft.AspNetCore.Mvc.Localization.dll                       System.Net.ServicePoint.dll
Microsoft.AspNetCore.Mvc.NewtonsoftJson.dll                     System.Net.Sockets.dll
Microsoft.AspNetCore.Mvc.Razor.dll                              System.Net.WebClient.dll
Microsoft.AspNetCore.Mvc.RazorPages.dll                         System.Net.WebHeaderCollection.dll
Microsoft.AspNetCore.Mvc.TagHelpers.dll                         System.Net.WebProxy.dll
Microsoft.AspNetCore.Mvc.ViewFeatures.dll                       System.Net.WebSockets.Client.dll
Microsoft.AspNetCore.Mvc.dll                                    System.Net.WebSockets.dll
Microsoft.AspNetCore.Razor.Runtime.dll                          System.Net.dll
Microsoft.AspNetCore.Razor.dll                                  System.Numerics.Vectors.dll
Microsoft.AspNetCore.ResponseCaching.Abstractions.dll           System.Numerics.dll
Microsoft.AspNetCore.ResponseCaching.dll                        System.ObjectModel.dll
Microsoft.AspNetCore.ResponseCompression.dll                    System.Private.CoreLib.dll
Microsoft.AspNetCore.Rewrite.dll                                System.Private.DataContractSerialization.dll
Microsoft.AspNetCore.Routing.Abstractions.dll                   System.Private.Uri.dll
Microsoft.AspNetCore.Routing.dll                                System.Private.Xml.Linq.dll
Microsoft.AspNetCore.Server.HttpSys.dll                         System.Private.Xml.dll
Microsoft.AspNetCore.Server.IIS.dll                             System.Reflection.DispatchProxy.dll
Microsoft.AspNetCore.Server.IISIntegration.dll                  System.Reflection.Emit.ILGeneration.dll
Microsoft.AspNetCore.Server.Kestrel.Core.dll                    System.Reflection.Emit.Lightweight.dll
Microsoft.AspNetCore.Server.Kestrel.Transport.Sockets.dll       System.Reflection.Emit.dll
Microsoft.AspNetCore.Server.Kestrel.dll                         System.Reflection.Extensions.dll
Microsoft.AspNetCore.Session.dll                                System.Reflection.Metadata.dll
Microsoft.AspNetCore.SignalR.Common.dll                         System.Reflection.Primitives.dll
Microsoft.AspNetCore.SignalR.Core.dll                           System.Reflection.TypeExtensions.dll
Microsoft.AspNetCore.SignalR.Protocols.Json.dll                 System.Reflection.dll
Microsoft.AspNetCore.SignalR.dll                                System.Resources.Reader.dll
Microsoft.AspNetCore.StaticFiles.dll                            System.Resources.ResourceManager.dll
Microsoft.AspNetCore.WebSockets.dll                             System.Resources.Writer.dll
Microsoft.AspNetCore.WebUtilities.dll                           System.Runtime.Caching.dll
Microsoft.AspNetCore.dll                                        System.Runtime.CompilerServices.Unsafe.dll
Microsoft.CSharp.dll                                            System.Runtime.CompilerServices.VisualC.dll
Microsoft.Data.SqlClient.dll                                    System.Runtime.Extensions.dll
Microsoft.EntityFrameworkCore.Abstractions.dll                  System.Runtime.Handles.dll
Microsoft.EntityFrameworkCore.Design.dll                        System.Runtime.InteropServices.RuntimeInformation.dll
Microsoft.EntityFrameworkCore.Relational.dll                    System.Runtime.InteropServices.WindowsRuntime.dll
Microsoft.EntityFrameworkCore.SqlServer.dll                     System.Runtime.InteropServices.dll
Microsoft.EntityFrameworkCore.dll                               System.Runtime.Intrinsics.dll
Microsoft.Extensions.Caching.Abstractions.dll                   System.Runtime.Loader.dll
Microsoft.Extensions.Caching.Memory.dll                         System.Runtime.Numerics.dll
Microsoft.Extensions.Configuration.Abstractions.dll             System.Runtime.Serialization.Formatters.dll
Microsoft.Extensions.Configuration.Binder.dll                   System.Runtime.Serialization.Json.dll
Microsoft.Extensions.Configuration.CommandLine.dll              System.Runtime.Serialization.Primitives.dll
Microsoft.Extensions.Configuration.EnvironmentVariables.dll     System.Runtime.Serialization.Xml.dll
Microsoft.Extensions.Configuration.FileExtensions.dll           System.Runtime.Serialization.dll
Microsoft.Extensions.Configuration.Ini.dll                      System.Runtime.WindowsRuntime.UI.Xaml.dll
Microsoft.Extensions.Configuration.Json.dll                     System.Runtime.WindowsRuntime.dll
Microsoft.Extensions.Configuration.KeyPerFile.dll               System.Runtime.dll
Microsoft.Extensions.Configuration.UserSecrets.dll              System.Security.AccessControl.dll
Microsoft.Extensions.Configuration.Xml.dll                      System.Security.Claims.dll
Microsoft.Extensions.Configuration.dll                          System.Security.Cryptography.Algorithms.dll
Microsoft.Extensions.DependencyInjection.Abstractions.dll       System.Security.Cryptography.Cng.dll
Microsoft.Extensions.DependencyInjection.dll                    System.Security.Cryptography.Csp.dll
Microsoft.Extensions.Diagnostics.HealthChecks.Abstractions.dll  System.Security.Cryptography.Encoding.dll
Microsoft.Extensions.Diagnostics.HealthChecks.dll               System.Security.Cryptography.Native.OpenSsl.a
Microsoft.Extensions.FileProviders.Abstractions.dll             System.Security.Cryptography.Native.OpenSsl.so
Microsoft.Extensions.FileProviders.Composite.dll                System.Security.Cryptography.OpenSsl.dll
Microsoft.Extensions.FileProviders.Embedded.dll                 System.Security.Cryptography.Pkcs.dll
Microsoft.Extensions.FileProviders.Physical.dll                 System.Security.Cryptography.Primitives.dll
Microsoft.Extensions.FileSystemGlobbing.dll                     System.Security.Cryptography.ProtectedData.dll
Microsoft.Extensions.Hosting.Abstractions.dll                   System.Security.Cryptography.X509Certificates.dll
Microsoft.Extensions.Hosting.dll                                System.Security.Cryptography.Xml.dll
Microsoft.Extensions.Http.dll                                   System.Security.Permissions.dll
Microsoft.Extensions.Identity.Core.dll                          System.Security.Principal.Windows.dll
Microsoft.Extensions.Identity.Stores.dll                        System.Security.Principal.dll
Microsoft.Extensions.Localization.Abstractions.dll              System.Security.SecureString.dll
Microsoft.Extensions.Localization.dll                           System.Security.dll
Microsoft.Extensions.Logging.Abstractions.dll                   System.ServiceModel.Web.dll
Microsoft.Extensions.Logging.Configuration.dll                  System.ServiceProcess.dll
Microsoft.Extensions.Logging.Console.dll                        System.Text.Encoding.CodePages.dll
Microsoft.Extensions.Logging.Debug.dll                          System.Text.Encoding.Extensions.dll
Microsoft.Extensions.Logging.EventLog.dll                       System.Text.Encoding.dll
Microsoft.Extensions.Logging.EventSource.dll                    System.Text.Encodings.Web.dll
Microsoft.Extensions.Logging.TraceSource.dll                    System.Text.Json.dll
Microsoft.Extensions.Logging.dll                                System.Text.RegularExpressions.dll
Microsoft.Extensions.ObjectPool.dll                             System.Threading.Channels.dll
Microsoft.Extensions.Options.ConfigurationExtensions.dll        System.Threading.Overlapped.dll
Microsoft.Extensions.Options.DataAnnotations.dll                System.Threading.Tasks.Dataflow.dll
Microsoft.Extensions.Options.dll                                System.Threading.Tasks.Extensions.dll
Microsoft.Extensions.Primitives.dll                             System.Threading.Tasks.Parallel.dll
Microsoft.Extensions.WebEncoders.dll                            System.Threading.Tasks.dll
Microsoft.Identity.Client.dll                                   System.Threading.Thread.dll
Microsoft.IdentityModel.JsonWebTokens.dll                       System.Threading.ThreadPool.dll
Microsoft.IdentityModel.Logging.dll                             System.Threading.Timer.dll
Microsoft.IdentityModel.Protocols.OpenIdConnect.dll             System.Threading.dll
Microsoft.IdentityModel.Protocols.dll                           System.Transactions.Local.dll
Microsoft.IdentityModel.Tokens.dll                              System.Transactions.dll
Microsoft.JSInterop.dll                                         System.ValueTuple.dll
Microsoft.Net.Http.Headers.dll                                  System.Web.HttpUtility.dll
Microsoft.VisualBasic.Core.dll                                  System.Web.dll
Microsoft.VisualBasic.dll                                       System.Windows.Extensions.dll
Microsoft.Win32.Primitives.dll                                  System.Windows.dll
Microsoft.Win32.Registry.dll                                    System.Xml.Linq.dll
Microsoft.Win32.SystemEvents.dll                                System.Xml.ReaderWriter.dll
MimeKit.dll                                                     System.Xml.Serialization.dll
Newtonsoft.Json.Bson.dll                                        System.Xml.XDocument.dll
Newtonsoft.Json.dll                                             System.Xml.XPath.XDocument.dll
Razorpay.dll                                                    System.Xml.XPath.dll
SOS_README.md                                                   System.Xml.XmlDocument.dll
System.AppContext.dll                                           System.Xml.XmlSerializer.dll
System.Buffers.dll                                              System.Xml.dll
System.Collections.Concurrent.dll                               System.dll
System.Collections.Immutable.dll                                WindowsBase.dll
System.Collections.NonGeneric.dll                               appsettings.Development.json
System.Collections.Specialized.dll                              createdump
System.Collections.dll                                          libclrjit.so
System.ComponentModel.Annotations.dll                           libcoreclr.so
System.ComponentModel.DataAnnotations.dll                       libcoreclrtraceptprovider.so
System.ComponentModel.EventBasedAsync.dll                       libdbgshim.so
System.ComponentModel.Primitives.dll                            libhostfxr.so
System.ComponentModel.TypeConverter.dll                         libhostpolicy.so
System.ComponentModel.dll                                       libmscordaccore.so
System.Configuration.ConfigurationManager.dll                   libmscordbi.so
System.Configuration.dll                                        mscorlib.dll
System.Console.dll                                              netstandard.dll
System.Core.dll                                                 web.config
System.Data.Common.dll                                          wwwroot
System.Data.DataSetExtensions.dll
jincod commented 2 years ago

Could you please do this locally?

dotnet buplish your-project.csproj -o output_dir
ls output_dir
pkaiche commented 2 years ago

I did this locally. The Content folder is not generated in the output_dir folder.

jincod commented 2 years ago

Sorry, I don't have any other idea

pkaiche commented 2 years ago

@jincod Thanks for your help.

After some tries, I had luck in getting my issue resolved. I added the below configuration in my-project.csproj file and now I am getting the required resource files inside the heroku_output/Content/ path.

image

Reference to this solution is here.

I had to add a separate Copy tag for each file to be copied which is somewhat cumbersome but eventually had my issue fixed.

Hope this helps someone in need.