ZimmertyZim
08/01/2024, 4:29 PM"ModelsBuilder": {
"ModelsMode": "SourceCodeManual",
"ModelsDirectory": "~/../MyProject.Models",
"ModelsNamespace": "MyProject.Models",
"AcceptUnsafeModelsDirectory": true,
"FlagOutOfDateModels": true
}
This works locally: I generate the models, see them added to my class library, build successfully, and the application runs without issues.
However, when deploying to staging, I encounter an ambiguous reference error. It seems to reference Umbraco.Cms.Web.Common.PublishedModels instead of MyProject.Models. It’s almost as if the appSettings.Staging configuration is being ignored.
I’ve added the same settings to the base appSettings. I suspect the the staging configuration is ignored; as the back office prompts for connection details during the first boot and then adds the connection string to the default appSettings file.
Comparing with another site that has the same settings/setup and generates .cs files in the MyProject.Models folder, my newly deployed site only generates a .dll.
I can’t find any differences in the build/publish profiles, Program.cs, appSettings, etc.
Is there something obvious I’m missing? Why would it work locally but fail on the server?huwred
08/01/2024, 5:04 PMAmbert
08/01/2024, 6:44 PMZimmertyZim
08/01/2024, 8:37 PMASPNETCORE_ENVIRONMENT
I can see this in the result web.config
Program.cs snippet:
.ConfigureAppConfiguration((hostContext, configBuilder) =>
{
configBuilder
.SetBasePath(Directory.GetCurrentDirectory())
.AddJsonFile("appsettings.json")
.AddJsonFile($"appsettings.{hostContext.HostingEnvironment.EnvironmentName}.json", optional: true, reloadOnChange: true)
.Build();
});
and then my publish profile (manual deployments for now):
<Project>
<PropertyGroup>
<DeleteExistingFiles>true</DeleteExistingFiles>
<ExcludeApp_Data>false</ExcludeApp_Data>
<LaunchSiteAfterPublish>true</LaunchSiteAfterPublish>
<LastUsedBuildConfiguration>Staging</LastUsedBuildConfiguration>
<LastUsedPlatform>Any CPU</LastUsedPlatform>
<PublishProvider>FileSystem</PublishProvider>
<PublishUrl>bin\Staging</PublishUrl>
<WebPublishMethod>FileSystem</WebPublishMethod>
<_TargetId>Folder</_TargetId>
<SelfContained>false</SelfContained>
<EnvironmentName>Staging</EnvironmentName>
<RuntimeIdentifier>win-x64</RuntimeIdentifier>
<SiteUrlToLaunchAfterPublish />
<TargetFramework>net6.0</TargetFramework>
<ProjectGuid>c55c6690-ad61-453d-bd09-1e9a7a60f20f</ProjectGuid>
</PropertyGroup>
</Project>
Ambert
08/02/2024, 5:47 AMAmbert
08/02/2024, 5:47 AMhostContext.HostingEnvironment.EnvironmentName
will return something elseZimmertyZim
08/02/2024, 8:45 AMtekoScott
08/05/2024, 3:05 AMZimmertyZim
08/20/2024, 2:50 PMA hub and casual space for you to interact with fellow community members and learn more about Umbraco!
Powered by