Reputation: 4274
I have a project that we can publish vis Visual Studio and Web Deploy, but we'd like to use a Folder deploy for some command line automation we're setting up. However, the Folder deploy is not working. The publish succeeds, but the website doesn't function. I get a 401.
When I do the Web Deploy, I see this in the Output:
1>------ Build started: Project: My.API, Configuration: Debug Any CPU ------
1>My.API -> C:\Users\myusername\source\repos\my-company\my-api\src\My.API\bin\Debug\net8.0\My.API.dll
2>------ Publish started: Project: My.API, Configuration: Debug Any CPU ------
My.API -> C:\Users\myusername\source\repos\my-company\my-api\src\My.API\bin\Debug\net8.0\My.API.dll
My.API -> C:\Users\myusername\source\repos\my-company\my-api\src\My.API\obj\Debug\net8.0\PubTmp\Out\
Updating file (My API Test\My.API.deps.json).
Updating file (My API Test\My.API.dll).
Updating file (My API Test\My.API.exe).
Updating file (My API Test\My.API.pdb).
Updating file (My API Test\web.config).
Publish Succeeded.
========== Build: 1 succeeded, 0 failed, 0 up-to-date, 0 skipped ==========
========== Build completed at 10:22 AM and took 25.755 seconds ==========
========== Publish: 1 succeeded, 0 failed, 0 skipped ==========
========== Publish completed at 10:22 AM and took 25.755 seconds ==========
When I do the folder deploy, I see this:
1>------ Build started: Project: My.API, Configuration: Debug Any CPU ------
1>My.API -> C:\Users\myusername\source\repos\my-company\my-api\src\My.API\bin\Debug\net8.0\My.API.dll
2>------ Publish started: Project: My.API, Configuration: Debug Any CPU ------
Connecting to \\webserver\c$\inetpub\My API Test...
My.API -> C:\Users\myusername\source\repos\my-company\my-api\src\My.API\bin\Debug\net8.0\My.API.dll
My.API -> C:\Users\myusername\source\repos\my-company\my-api\src\My.API\obj\Debug\net8.0\PubTmp\Out\
Web App was published successfully file://webserver/c$/inetpub/My%20API%20Test
========== Build: 1 succeeded, 0 failed, 0 up-to-date, 0 skipped ==========
========== Build completed at 10:21 AM and took 04.707 seconds ==========
========== Publish: 1 succeeded, 0 failed, 0 skipped ==========
========== Publish completed at 10:21 AM and took 04.707 seconds ==========
My Web Deploy pubxml looks like this:
<?xml version="1.0" encoding="utf-8"?>
<Project>
<PropertyGroup>
<_SavePWD>false</_SavePWD>
<_TargetId>IISWebDeploy</_TargetId>
<AllowUntrustedCertificate>true</AllowUntrustedCertificate>
<DeployIisAppPath>My API Test</DeployIisAppPath>
<EnableMSDeployBackup>true</EnableMSDeployBackup>
<EnableMsDeployAppOffline>true</EnableMsDeployAppOffline>
<EnvironmentName>Development</EnvironmentName>
<ExcludeApp_Data>false</ExcludeApp_Data>
<LaunchSiteAfterPublish>false</LaunchSiteAfterPublish>
<LastUsedBuildConfiguration>Debug</LastUsedBuildConfiguration>
<LastUsedPlatform>Any CPU</LastUsedPlatform>
<MSDeployPublishMethod>WMSVC</MSDeployPublishMethod>
<MSDeployServiceURL>WEBSERVER</MSDeployServiceURL>
<ProjectGuid>882aa1bc-7efc-42b3-afa6-07611234eb12</ProjectGuid>
<RemoteSitePhysicalPath />
<SelfContained>false</SelfContained>
<SkipExtraFilesOnServer>true</SkipExtraFilesOnServer>
<TargetFramework>net8.0</TargetFramework>
<UserName>company\myusername-a</UserName>
<WebPublishMethod>MSDeploy</WebPublishMethod>
</PropertyGroup>
</Project>
My folder deploy pubxml:
<?xml version="1.0" encoding="utf-8"?>
<Project>
<PropertyGroup>
<_TargetId>Folder</_TargetId>
<DeleteExistingFiles>true</DeleteExistingFiles>
<ExcludeApp_Data>false</ExcludeApp_Data>
<LaunchSiteAfterPublish>false</LaunchSiteAfterPublish>
<LastUsedBuildConfiguration>Debug</LastUsedBuildConfiguration>
<LastUsedPlatform>Any CPU</LastUsedPlatform>
<ProjectGuid>882aa1bc-7efc-42b3-afa6-07611234eb12</ProjectGuid>
<PublishProvider>FileSystem</PublishProvider>
<PublishUrl>\\webserver\c$\inetpub\My API Test</PublishUrl>
<SelfContained>false</SelfContained>
<SiteUrlToLaunchAfterPublish />
<TargetFramework>net8.0</TargetFramework>
<WebPublishMethod>FileSystem</WebPublishMethod>
</PropertyGroup>
</Project>
I'm wondering if I'm missing a setting or step with the folder deploy.
Upvotes: 0
Views: 17
Reputation: 4274
I figured out why I was getting the 401, and I figured out how to fix it going forward.
The folder profile was not including the Environment variable (which I can see now in the Web Deploy.) So the web.config was not getting this
<environmentVariables>
<environmentVariable name="ASPNETCORE_ENVIRONMENT" value="Development" />
</environmentVariables>
Putting that in fixed the site, but I needed to get that in there every time. I found this:
How to set ASPNETCORE_ENVIRONMENT to be considered for publishing an ASP.NET Core application
It was a simple fix, and a dumb thing to miss, but it's a Friday, and it's been a long week.
Upvotes: 0