C
C#6mo ago
Kobayashi

Errors while trying to build a VSA template

https://github.com/viceroypenguin/VsaTemplate/ I got errors while trying to build this template
GitHub
GitHub - viceroypenguin/VsaTemplate
Contribute to viceroypenguin/VsaTemplate development by creating an account on GitHub.
32 Replies
Kobayashi
Kobayashi6mo ago
@viceroypenguin | 🦋🐧
viceroypenguin
viceroypenguin6mo ago
I’ll keep this unread and answer this afternoon. Am busy this morning and can’t go into detail atm. ok, looks like it's tryign to connect to localhost, with blank username and blank password. is this what you intended? you'll need to point this to a proper mssql server, with the right username/pass that has enough perms to create and drop a database.
Kobayashi
Kobayashi6mo ago
Happy new year I hope you had fun time with family and loved ones
Severity Code Description Project File Line Suppression State Details
Error MSB3073 The command ""C:\Users\User\source\repos\VsaTemplate\Scaffold\/bin/Debug/Scaffold" --output-file="C:\Users\User\source\repos\VsaTemplate\Services\Database/Models/Scaffold.g.cs" --context-namespace="VsaTemplate.Database" --model-namespace="VsaTemplate.Database.Models" --connection-string="Server=DESKTOP-9FQOABF;User=admin;Password=password;app=VsaTemplate.scaffold" -- "C:\Users\User\source\repos\VsaTemplate\Services\Database\Scripts\00.VersionHistory.sql" "C:\Users\User\source\repos\VsaTemplate\Services\Database\Scripts\01.Hangfire.v9.sql" "C:\Users\User\source\repos\VsaTemplate\Services\Database\Scripts\2023-08-27.01.User.sql" "C:\Users\User\source\repos\VsaTemplate\Services\Database\Scripts\2023-08-27.02.Feature.sql"" exited with code 1. Services C:\Users\User\source\repos\VsaTemplate\Scaffold\Scaffold.targets 48
Severity Code Description Project File Line Suppression State Details
Error MSB3073 The command ""C:\Users\User\source\repos\VsaTemplate\Scaffold\/bin/Debug/Scaffold" --output-file="C:\Users\User\source\repos\VsaTemplate\Services\Database/Models/Scaffold.g.cs" --context-namespace="VsaTemplate.Database" --model-namespace="VsaTemplate.Database.Models" --connection-string="Server=DESKTOP-9FQOABF;User=admin;Password=password;app=VsaTemplate.scaffold" -- "C:\Users\User\source\repos\VsaTemplate\Services\Database\Scripts\00.VersionHistory.sql" "C:\Users\User\source\repos\VsaTemplate\Services\Database\Scripts\01.Hangfire.v9.sql" "C:\Users\User\source\repos\VsaTemplate\Services\Database\Scripts\2023-08-27.01.User.sql" "C:\Users\User\source\repos\VsaTemplate\Services\Database\Scripts\2023-08-27.02.Feature.sql"" exited with code 1. Services C:\Users\User\source\repos\VsaTemplate\Scaffold\Scaffold.targets 48
I created new user and enabled on server security allow login with user and password and it worked connecting using same creds in Server Manager added %3BEncrypt=False to scaffold connection string and it worked now
{
"DbContextOptions": {
"ConnectionString": "Data Source=DESKTOP-9FQOABF;Initial Catalog=vsatest;User ID=admin;Password=password;Encrypt=False"
},
{
"DbContextOptions": {
"ConnectionString": "Data Source=DESKTOP-9FQOABF;Initial Catalog=vsatest;User ID=admin;Password=password;Encrypt=False"
},
inside Web/secrets.json
viceroypenguin
viceroypenguin6mo ago
debug program.cs, breakpoint on line 33, and check that DbContextOptions:ConnectionString has a value oh. the sourcegen isn't working right. hold on
Kobayashi
Kobayashi6mo ago
it's when running Web project
viceroypenguin
viceroypenguin6mo ago
yeah, but the bug is in the sourcegen project. ConfigureOptionsGenerator.cs:L15 - change to "VsaTemplate.ConfigureOptionsAttribute" same for EnumDatabaseSyncGenerator:L16 - add VsaTemplate. to the beginning of that string too i'll fix it in my next release of the vsa tempalte
Kobayashi
Kobayashi6mo ago
it worked now should I open a gh issue
viceroypenguin
viceroypenguin6mo ago
nah, i've got it changed on mine already
Kobayashi
Kobayashi6mo ago
so you can remember it? okay cool thanks
viceroypenguin
viceroypenguin6mo ago
sure!
Kobayashi
Kobayashi6mo ago
I added to Auth0 the redirect URL also in configurations you are not using client secret, I am familiar with google auth, and it requires the client secret to be also specified it's https://localhost:7013/callback
viceroypenguin
viceroypenguin6mo ago
if i remember right, the secret is only necessary for JS API with an API server
Kobayashi
Kobayashi6mo ago
I figured it out, but still gives an error
viceroypenguin
viceroypenguin6mo ago
which is probably where the thing will go next, but i haven't gotten there. with the existing stuff, i haven't needed the secret value
Kobayashi
Kobayashi6mo ago
I see
viceroypenguin
viceroypenguin6mo ago
so what error are you getting now?
Kobayashi
Kobayashi6mo ago
I just need the thing to work, I need to convert it to API based and upgrade to .net 8 I am trying to make my own version out of this and start building my production API using it one in picture above this
viceroypenguin
viceroypenguin6mo ago
interesting... on the auth0 side, do you ahve a connection set up to authenticate users? something like
Kobayashi
Kobayashi6mo ago
yes
viceroypenguin
viceroypenguin6mo ago
hmm.... if you go here do you have the app enabled for the connection?
Kobayashi
Kobayashi6mo ago
I created new app now it's working
viceroypenguin
viceroypenguin6mo ago
there's one last thing that i didn't document that i need to you have to finagle auth0 to pass roles which i don't know why they don't share roles by default
Kobayashi
Kobayashi6mo ago
I am new to auth0, I will check how I can do that
viceroypenguin
viceroypenguin6mo ago
under Actions > Flows > Login add a new flow
Kobayashi
Kobayashi6mo ago
viceroypenguin
viceroypenguin6mo ago
add a new custom action "Add Roles to ID"
Kobayashi
Kobayashi6mo ago
did that
viceroypenguin
viceroypenguin6mo ago
when you get to the code, update the post login method to as such:
exports.onExecutePostLogin = async (event, api) => {
const assignedRoles = (event.authorization || {}).roles;

if (event.authorization) {
api.idToken.setCustomClaim('http://schemas.microsoft.com/ws/2008/06/identity/claims/role', assignedRoles);
api.accessToken.setCustomClaim('http://schemas.microsoft.com/ws/2008/06/identity/claims/role', assignedRoles);
}
};
exports.onExecutePostLogin = async (event, api) => {
const assignedRoles = (event.authorization || {}).roles;

if (event.authorization) {
api.idToken.setCustomClaim('http://schemas.microsoft.com/ws/2008/06/identity/claims/role', assignedRoles);
api.accessToken.setCustomClaim('http://schemas.microsoft.com/ws/2008/06/identity/claims/role', assignedRoles);
}
};
Kobayashi
Kobayashi6mo ago
nothing changed before was working without doing that like I was able to login and create features before and after is the same
viceroypenguin
viceroypenguin6mo ago
if you add yourself to the Admin role then you'll have access to hangfire, swagger, etc.
Kobayashi
Kobayashi6mo ago
ahh okay, I will take a look at that all working now thanks
viceroypenguin
viceroypenguin6mo ago
sure thing!