Cannot generate models outside of project, even wi...
# help-with-umbraco
p
Hello, I am trying to keep my generated model inside of a project called "Web", which is a normal csharp classlib project which references Umbraco.Cms.Core and Umbraco.Cms.Infrastructure. My Umbraco project, is called Web.UI. and here's my appsettings.json for the modelsbuilder: "ModelsBuilder": { "ModelsMode": "SourceCodeManual", "AccceptUnsafeModelsDirectory": true, "ModelsDirectory": "~/../Web/models", "ModelsNamespace": "ACME.Web.Models" } even so, when opening the modelsbuilder under the Settings section in the backoffice, im getting a red popup telling me the path is wrong. Please advise!
m
You dont need the ~/ just ../
p
@Matt Wise that doesn't work either
my folder structure
i can only set paths inside of the Web.UI project
it's as if it doesn't accept the AcceptUnsafeModelsDirectory setting
this is a fresh Umbraco 14 installation @Matt Wise , im only just getting everything setup so i'm at a lost why this is not working
m
Are you using IIS epxress or kestrel?
p
i think it's kestrel if you are just debugging from vsvode or using dotnet run, right?
yeah i think it's kestrel
m
Yeah that would be kestrel
so it should have the same permissions as you
p
yeah it should, hmm
m
if you look in the log veiwer does it give you anymore info?
p
(thanks for helping me Matt)
it just tells me pretty much the same
m
Just looking at the docs and ~ is allowed, but I have never bothered I swear 😄
p
you usually keep the published models in the same directory?
maybe im foolishing trying do divide things up
m
No I normally move them just checking my repo now and I hav a ~ 😄
p
same project* i meant to save
you move them to a separe project by hand?
(or by script=)
m
Copy code
"ModelsBuilder": {
   "AcceptUnsafeModelsDirectory": true,
   "FlagOutOfDateModels": true,
   "ModelsMode": "SourceCodeAuto",
   "ModelsDirectory": "~/../Project.Models/UmbracoGenerated"
 }
p
wth
m
Is what I have on a v13 project
p
i am running v14
😦
the docs are still the same though
m
I dont think its changed in 14 certainly the docs reflect the same configuration
~/../Models work?
p
that should place it under a Models directory, on the same Level as my Web and Web.UI project
m
I wonder if vscode has some sort lock on the folder?
p
im running it from dotnet run
now
gonna try and close vscode
no that didn't help either
it's like as soon as i use ".." it stops working
maybe i can set this programatically somehow
with a composer
well
that probadly aint the issue
:(( i really want to get this to work, wonder if it's an issue with umbraco 14
m
don't think it's a v14 issue (although there are plenty of others) as working for me with a vanilla install and just copied @Matt Wise settings into
appsettings.development.json
only thing I did have to do was spin up the site and go
settings -> modelsbuilder -> generate models
as sourcecodeauto doesn't do an initial generation on build if no models found.
p
hmm, wth
@Mike Chambers your ProjectModels directory, is that already an csharp project?
just tried
m
nope.. wasn't anything there till models builder kicked in and generated the folder
p
nah, it's not working for me at all 😦
im gonna try putting in into appsettings.Development.json
m
(and that's litterally all it's done.. generated the folder and cs files.. so wouldn't work as it needs to be a class library, but that's down to the developer to expect to do that)
p
it's still giving me the error
it just won't accept any paths not inside the same project
m
is it a local file permissions issue?
p
hold on a bit
maybe
i'll check
maybe i can run it as root or something
starting it from Visual Studio now, rather then vscode or dotnet run
m
are the files in your %userprofile% folder?
p
yeah
under source/repos/blahalalal/myprject
m
ok so might be perms then.. as your folder will be restricted to you... and the aspnet process will be running under an apppool user
do you have a separate partition you can move the files too?
p
no sadly, gonna try and create a entirely new project once more
m
or you need to add read/write perms for ...
p
you used dotnet new umbraco right?
m
yeah but not in my user directory.. on a dedicated partition using devdrive....
p
oh
you are using this?
m
yep
just from the supposed faster build times..
let me try moving the project into my userprofile to see if I get the same issue
p
with a brand new project it worked
it's now onder my profile
utest/Site
and utest/ProjectModels (the generated one)
gonna try moving the project i was working on
m
sounds like progress...
just thought... dotnet run.. will run in release mode.. so settings in appsettings.development.json won't apply
so would need to have them in appsettings.json or appsettings.production.json for that
not sure what environment vscode would run in.
I think you can do
dotnet run -c Developement
ps all working for me from
/user/m/source/repo/project
in kestrel.. might be iis(express) where you have issues with appppoolidentity needing write access.
p
i moved the entire project into straight to %userprofile%
now it doesn't work
m
ntfs permissions will be copied too.. if it is that.
p
ah
hmm
wonder what i can do
m
if you don't specify unsafe and models directory.. do the models get generated in the
umbraco/models
folder?
in case it's a appsettings issue, you could try using your uTest ones in this project?
and you can always check the permissions on the folders?
Sorry it's not a quick win.. 😦
p
how are you creating your umbraco project @Mike Chambers ?
using the dotnet cli?
m
yup, via the excellent https://psw.codeshare.co.uk/
p
ah, you are on umbraco-cloud. I am not
m
nope not on cloud..
just lifting the cli commands from there to generate some additional class librarys
p
ah i was just going by the link
but you are on 13
maybe i ought to just be on 13 aswell
m
nope 14..
p
okay
then
then
i should just create the project a new
get the modelsidrectory to work, and go on from there
i've tried setting permissions on folders to be readable/writable for everyone
m
I would say though only playing with 14 as yet.. I'm not convinced it's production ready...
p
yeah maybe that's reason enough to be on 13
m
still missing functionality that we use.. like grid previews.
and migration of custom propeditors/dashboards/sections/trees etc over to the new (lit) web components.. isn't all that easy.. at least for me.
p
i have a task ahead of me to upgrade form umbraco 8 to 13
very daunting
the 8 site is messed up
just made a new project, umbraco 13, straight in my %userprofile% directory. still getting the invalid models path issue.. what is going on
tried with just "../" now
"~/../" also fails. it is impossible to have it create the models in a separate project
even tried creating the project from straight on the C:/ now
still the same issue
this is very vexxing....
k
This works for me on a new 14 project.
"ModelsBuilder": {
"ModelsMode": "SourceCodeAuto",
"AcceptUnsafeModelsDirectory": true,
"ModelsNamespace": "x.Model",
"ModelsDirectory": "~/../x.Model"
},
The directory was setup using an empty C# class library project
I'm using Visual Studio though, so not sure if
dotnet run
is the culprit.
8 Views