Custom Section on Production not working
# help-with-umbraco
u
Im currently having a problem with my umbraco applicaiton. I have created multiple custom section in umbraco. Each Section has a package.manifest file which includes references to the files i need such as angular controller js files etc. (All in App_Plugins). It all works as it should on my computer. For some reason when I publish it to my server i get an error that says that there is no registered controller with that name. I checked everything and no files are missing. The wierd thing is that when i publish the application I have to seperatly clone my app_plugins folder to the published folder. Is there a way to fix this? Umbraco Version : 12.0.1
a
Hi Suje Might be because your runtime minification is set to Version, which is typically what you would do in production. If this is the case, you can bump the version count via the Version setting in your appsettings.json file. You can read more about this here: https://docs.umbraco.com/umbraco-cms/reference/configuration/runtimeminificationsettings
k
Hi, the simple way is i think put your files in
wwwroot/App_Plugins
, this should be part of the published package when the site is built, there are more detailed and complex ways, essentially you should treat the custom code like a package. https://docs.umbraco.com/umbraco-cms/extending/packages/creating-a-package and then they will deploy more like code and can be moved between soloutions, but i think moving to
wwwroot/App_Plugins
, is the quick and dirty way of you not having to seperatly clone them (umbraco merges /App_Plugins and
wwwroot/App_Plugins
, so they look like one folder). Also , and i can't remember this there is a setting you can add to the .csproj to make /App_Plugins be part of the published site, (then you wouldn't have to move them
a
If the files are there, but you don't see the changes in the backoffice, I'd say it's an minification issue like I described. If you had to copy the files manually to be there in the first please, then Kevin has a point as well. I typically don't put App_Plugins inside the
wwwroot
folder, but there shouldn't be any problem in doing so. To ensure that App_Plugins files are in fact copied to the output directory when doing a deploy, you can add something like this to your .csproj file:
Copy code
xml
  <ItemGroup>
    <Content Include="App_Plugins\YourName\**\*">
      <CopyToOutputDirectory>Always</CopyToOutputDirectory>
    </Content>
    <Content Include="App_Plugins\YourName.Section1\**\*">
      <CopyToOutputDirectory>Always</CopyToOutputDirectory>
    </Content>
    <Content Include="App_Plugins\YourName.Section2\**\*">
      <CopyToOutputDirectory>Always</CopyToOutputDirectory>
    </Content>
  </ItemGroup>
or something like:
Copy code
xml
  <ItemGroup>
    <Content Include="App_Plugins\**\*">
      <CopyToOutputDirectory>Always</CopyToOutputDirectory>
    </Content>
  </ItemGroup>
k
Yes they are the settings I can never remember 😊
a
Yeah - I knew I had recently used it in a project. But back then I used the Visual Studio UI for setting it for a single file, and then added the asterisks manually. The UI doesn't seem to support doing this for a folder.
a
3ed option, is it hosted on linux?
It is case sensitive, double check your casings in paths 😜
u
Hey thank you guys for your quick responses. I have tried everything you have suggested me to try and it still doesnt work. All the sections are now being displayed in my umbraco backoffice which is good. But for some reason all the angular js files i have created wont get recognised by umbraco. I get the following error: I checked my directories and they are all complete. I even moved the app_plugins folder to wwwroot but it still doesnt work. Is it a version bug? should i try to upgrade my umbraco?
p
@User May I suggest β€œall” instead of "guys"? We use gender inclusive language in this Discord. πŸ˜€
u
I have also bumped up the version count but it still doesnt work...
a
Can you share a bit of your code? Eg. your package.manifest and the JS file with the controller? What hosting platform are you using? As mentioned by Ambert, if the casing is wrong on Linux, you will get 404 errors.
u
Im hosting my application on a windows server. Yes sure.
Do you need anything else?
Is mentioned before everything works on my computer but not on the server :/
a
I've never seen an Angular controller wrapped in jQuery's document ready event. Might be worth removing that. But if it works locally, that probably isn't what causes issues on the live site.
u
yes i can try to remove it but if that would be an issue wouldnt i get a jquery error or something?
a
I don't think you'll get errors from removing that. The controller will be registered at page load, but the controller logic it self will be called when your dashboard is added to the DOM. So jQuery should be loaded and ready at this point.
Anyways - most of the .js files in your screenshot look minified. I think if for instance one of them strip of a semi colon at the end, or something similar, that could cause issues as well. Do you see other errors in the JS console than the screenshot you shared yesterday?
u
Hmm i see. I can check each js file for semi colons. Yes i have get the following error as well:
a
So one of those minified files probably doesn't include a semi colon in the end, so it causes errors when they are merged into the same file.
You can try find the one with the issue, or you can disable bundling for your files by adding
"bundleOptions": "None"
to your
package.manifest
.
u
hmm im getting still the same error. Do you know if every js file in every section I created are being merged in to one min file? Or each section has a min js file with all the corresponding js files?
a
If you don't specify
bundleOptions
in your manifest, all backoffice extensions get merged into one
.js
file. That's the
umbraco-backoffice-extensions-js.js
that you can see from your last screenshot. By adding
"bundleOptions": "None"
it should tell Umbraco to not bundle or minify your JS files, but serve them individually. There is also
"bundleOptions": "Independent"
, which tells Umbraco to create a separate bundle for your files.
u
Hmm i see. I removed every section besides 2. And to both of them i added "bundleOptions": "None" to the package.manifest. It works :). I think I will go one by one and try to figure out where the problem could be. Thank you very much, you saved me xD.
2 Views