I want to deploy my .NET Core MVC application in an azure WebService. I have built the app locally with
dotnet publish
and moved the output code with the Kudu service in my wwwroot directory but the wabapp just gives me the errorpage:
deploy .NET Core CLI MVC application to azure web service
What am I doing wrong?
I tried with a sample project:
D:\dotnetDummy>dotnet publish
Microsoft (R) Build Engine version 15.3.409.57025 for .NET Core
Copyright (C) Microsoft Corporation. All rights reserved.
dotnetDummy -> D:\dotnetDummy\bin\Debug\netcoreapp2.0\dotnetDummy.dll
dotnetDummy -> D:\dotnetDummy\bin\Debug\netcoreapp2.0\publish\ <-- output directory
after publishing locally, you want to move all files under output directory to wwwroot folder of your azure webapp, in this case your D:\home\site\wwwroot on Kudu site should look the same as D:\dotnetDummy\bin\Debug\netcoreapp2.0\publish
D:\dotnetDummy\bin\Debug\netcoreapp2.0\publish>dir /B
dotnetDummy.deps.json
dotnetDummy.dll
dotnetDummy.pdb
dotnetDummy.PrecompiledViews.dll
dotnetDummy.PrecompiledViews.pdb
dotnetDummy.runtimeconfig.json
web.config <-- output of dotnet publish
if you don't see web.config under wwwroot, I would guess there's a mistake during the move
Related
We have a UWP app with unit tests that run fine from Visual Studio. However, we are running into issues when trying to run the tests on our build agent. To isolate the issue from our build pipeline, we have tried to run the tests using vstest.console.exe from the command line on our local build machine. The error below is the same regardless of whether we run from the build pipeline or from the command line. We would appreciate any guidance.
TestWindow>vstest.console.exe /Platform:x86 /Framework:FrameworkUap10
/InIsolation /logger:trx;LogFileName=%temp%\SampleUwpAppTest.trx
C:\vsts-agent_work\22\a\AppxPackages\SimpleUwpApp.Tests_1.0.0.0_x86_Test\SimpleUwpApp.Tests_1.0.0.0_x86.appx
Microsoft (R) Test Execution Command Line Tool Version 15.7.2
Copyright (c) Microsoft Corporation. All rights reserved.
Starting test execution, please wait... Attempting to deploy to target
'Local Machine'. Deployment operation succeeded, package moniker:
'7d25c824-2568-4449-a622-ad28662417f9_1.0.0.0_x86__a178p9x51fw8a'.
Attempting to launch app with app user model Id
'7d25c824-2568-4449-a622-ad28662417f9_a178p9x51fw8a!vstest.executionengine.universal.App' and arguments '--port 1428 --endpoint 127.0.0.1:01428 --role client
--parentprocessid 5744 --telemetryoptedin false'. DEP7100: Failed to activate app
'7d25c824-2568-4449-a622-ad28662417f9_a178p9x51fw8a!vstest.executionengine.universal.App' with parameters '--port 1428 --endpoint 127.0.0.1:01428 --role client
--parentprocessid 5744 --telemetryoptedin false'. Access is denied.
Access is denied.
App activation failed.
Microsoft.VisualStudio.TestPlatform.ObjectModel.TestPlatformException:
Failed to initialize client proxy: could not connect to test process.
at
Microsoft.VisualStudio.TestPlatform.CrossPlatEngine.Client.ProxyOperationManager.SetupChannel(IEnumerable`1
sources) at
Microsoft.VisualStudio.TestPlatform.CrossPlatEngine.Client.ProxyExecutionManager.StartTestRun(TestRunCriteria
testRunCriteria, ITestRunEventsHandler eventHandler) Closing app with
package full name
'7d25c824-2568-4449-a622-ad28662417f9_1.0.0.0_x86__a178p9x51fw8a'.
Test Run Aborted.
Build Information
Our sample solution has two projects: SimpleUwpApp and SimpleUwpApp.Tests. The former's project file has <AppxBundle>Always</AppxBundle> and the latter has <AppxBundle>Never</AppxBundle>. The build agent is a local Windows 10 machine which we have used for UWP builds for a while. Here is a screenshot of our build configuration in Azure DevOps:
You might see this error if developer mode is not enabled on the build agent.
You can enable developer mode in the Settings app, or set the AllowDevelopmentWithoutDevLicense registry key.
I ran across this issue today and eventually traced it to the way in which our Self-Hosted Azure DevOps agent was running - in order to run UWP Unit Tests you have to use Interactive mode for the Agent and not run it as a Windows Service. From the docs:
Visible UI testing using self-hosted Windows agents
Agents that are configured to run as service can run Selenium tests only with headless browsers. If you are not using a headless browser, or if you are running UI tests for desktop apps, Windows agents must be configured to run as an interactive process with auto-logon enabled.
After making this change I found the error went away.
We're running the following command for building and packaging Visual Studio Solutions:
MSBuild.exe *slnfile* /p:DeployOnBuild=true /p:CreatePackageOnPublish=true
It appears this creates packages for Web Applications but not Web Services. I don't even see a "Publish" option in Visual Studio for Web Service projects. How do I package these for deployment?
It turns out the developer didn't create a Web Application project, they created a simple empty C# project. I converted the project to Web Application and it works.
I have used .Net Core 2.0 to build my Web API. Now I am trying to deploy this project to AWS using its Elastic Beanstalk Service. I am also using the Visual Studios AWS deployment tool.
During the deployment process, I am receiving the following error;
Error during deployment: Could not find a part of the path
'C:\inetpub\AspNetCoreWebApps\app\appsettings.Development.json'.
I have added the following section into my .csproj;
<ItemGroup>
<Content Update="appsettings.json">
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
</Content>
<Content Update="appsettings.Development.json">
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
</Content>
</ItemGroup>
I can see that my appsettings.json and appsettings.Development.json are in my output folder when I build my project. Also they appear in the published directory if I publish the app into my local pc.
I could not understand why does Amazon's service can not pick it up...
Edit: So, interestingly I created a new .Net Core 2.0 Web Api project from Visual Studio templates and tried deploying it to AWS and it gave me the same error. However when I create an MVC project and deploy it to AWS everything works fine. The default settings for the web api template seems to be effecting the deployment somehow...
So I created a new .Net Core 2.0 MVC Project and migrated/adapted my web api to it. Now its deployed without any issues.
So if your project was started from a Web Api template and getting a simillar error, try switching between templates.
So after trial and error with including and excluding certain files, the problem is with WebApi because it does not have a wwwroot folder and it would appear the elastic beanstalk scripts are looking for this.
To make it work, I added a wwwroot folders and put a placeholder html file inside it and my project now deploys correctly!
Are you using AWS toolkit for VS 2017 to deploy your application. That would do a lot of the config work for you.
There are many problems with the AWS preconfigured environment for asp.net core 2 with IIS 10, try terminating your beanstalk environment and recreate and deploy through AWS toolkit directly from Visual Studio. Right click your project and use the "Publish to AWS Beanstalk"
I have created multiple sample project following the VS2017 .Net Core Web App template, targeting .Net Core and .NET Framework.
I have tested in all last three cumulative updates of VS2017; (i.e. Version 15.3.2, 15.3.3, 15.3.4)
Publishing to Web Deploy Package fails with the following error:
Target: .NET Core
Web deployment task failed. (Could not find file '\PublishTestNetCore.Parameters.xml'.) PublishTestNetCore C:\Program Files\dotnet\sdk\1.1.0\Sdks\Microsoft.NET.Sdk.Publish\build\netstandard1.0\PublishTargets\Microsoft.NET.Sdk.Publish.MSDeployPackage.targets 88
Target: .NET Framework 461
Web deployment task failed. (Could not find file '\TestPublish461.Parameters.xml'.) TestPublish461 C:\Program Files\dotnet\sdk\1.1.0\Sdks\Microsoft.NET.Sdk.Publish\build\netstandard1.0\PublishTargets\Microsoft.NET.Sdk.Publish.MSDeployPackage.targets 88
I am able to publish to IIS server though, but building the MSDeploy package always fail.
Thanks for any hint.
Mamrez
The issue was that the publish to package with latest VS 2017 cumulative updates required .NET Core 2.0 installed and that's odd!
I had to follow this link to install .NET Core 2.0 on my developer laptop to be able to publish MSDeploy packages that target non-.NET Core 2.0!!
[https://www.microsoft.com/net/core#windowscmd]
I am trying to deploy my web application and web service to Azure. I am somewhat new to web development and even newer to web app deployment.
When I test deployment on my local machine, there are 2 steps:
1) Publish web service from within VS. Copy generated folder to server's inetpub/wwwroot/ folder, convert to application from IIS manager. - I refer to this as the back end.
2) Host and run the web app. Run "grunt build" to generate a "dist" folder, copy dist folder into inetpub/wwwroot, create new site pointing to this folder in iis manager. - I refer to this as the front end.
I seem to have gotten step 1 done correctly in Azure: http://nxgnopencast.azurewebsites.net/ - published it to Azure from within Visual Studio.
My issue is step 2. What is the equivalent of grunt building and using iis manager to convert to website for Azure?
Try copying all of the content on your IIS website into the wwwroot folder on your Azure web app. This can be done easily via FTP or drag and drop on the SCM site: http://nxgnopencast.scm.azurewebsites.net/
On the SCM site go to Debug console > CMD and then use the folder structure to go to D:\home\site\wwwroot and drag and drop all of your content there.
For more deployment techniques see:
https://azure.microsoft.com/en-us/documentation/articles/web-sites-deploy/