I've worked on the new version of this blog for a while now - it got the official "works on my PC" badge and I felt the time was right to be able to upload and share with the world. So I setup my Azure Portal to enable me to deploy automatically from a check-in to the GitHub repository that contains the code. However, I immediately ran into a problem - the entire website wouldn't even start, let alone render correctly.
Initially, I had a problem even seeing the error - this was resolved by including the property
setting its value to
Development. This enables anyone to view the details of the error messages as they
happen on your website. Not a great thing to enable in a production site, but as I was still on the azurewebsites.net domain, I didn't
feel it was a problem for now.
After that was enabled, I was greeted by this error:
Command: "D:\some\path\to\site\deployments\tools\deploy.cmd" Handling ASP.NET Core Web Application deployment. Restore completed in 14.55 sec for D:\some\path\to\site\repository\Website\Website.csproj. Restore completed in 14.72 sec for D:\some\path\to\site\repository\Blog\Blog.csproj. Restore completed in 14.65 sec for D:\some\path\to\site\repository\Blog.Tests\Blog.Tests.csproj. Restore completed in 14.56 sec for D:\some\path\to\site\repository\Website.Tests\Website.Tests.csproj. Restore completed in 8.27 sec for D:\some\path\to\site\repository\Website\Website.csproj. Microsoft (R) Build Engine version 15.3.388.41745 for .NET Core Copyright (C) Microsoft Corporation. All rights reserved. D:\Program Files (x86)\dotnet\sdk\2.0.0-preview2-006497\Sdks\Microsoft.NET.Sdk\build\Microsoft.NET.Sdk.DefaultItems.targets(285,5): error : Duplicate 'Content' items were included. The .NET SDK includes 'Content' items from your project directory by default. You can either remove these items from your project file, or set the 'EnableDefaultContentItems' property to 'false' if you want to explicitly include them in your project file. For more information, see https://aka.ms/sdkimplicititems. The duplicate items were: 'wwwroot\css\partials\_social-media.scss' [D:\some\path\to\site\repository\Website\Website.csproj] Failed exitCode=1, command=dotnet publish "D:\some\path\to\site\repository\Website\Website.csproj" --output "D:\local\Temp\8d4bc7e784d0a7d" --configuration Release An error has occurred during web site deployment. \r\nD:\Program Files (x86)\SiteExtensions\Kudu\63.60712.2926\bin\Scripts\starter.cmd "D:\some\path\to\site\deployments\tools\deploy.cmd"
Obviously, Stack Overflow was the starting point when I stumbled upon this article. That article, as well as some of the Microsoft Documentation, offers the suggestion to turn off the DefaultContentItems section with the following line:
However, continuing to read through that Stack Overflow post came up gold. I had to go digging through an unloaded .csproj file. From there I found some content nodes to delete. As you can tell from the commit itself, I just took a hatchet to the project file and removed all the code that I didn't feel needed to be there. Committed, re-pushed and everything worked.
- <ItemGroup> - <Content Include="wwwroot\css\highlight\atom-one-dark.css" /> - <Content Include="wwwroot\css\highlight\atom-one-light.css" /> - <Content Include="wwwroot\css\highlight\github-gist.css" /> - <Content Include="wwwroot\css\highlight\github.css" /> - <Content Include="wwwroot\css\modules\_blog.scss" /> - <Content Include="wwwroot\css\modules\_homepage.scss" /> - <Content Include="wwwroot\css\modules\_my-name-is.scss" /> - <Content Include="wwwroot\css\modules\_aboutme.scss" /> - <Content Include="wwwroot\css\partials\_boxes.scss" /> - <Content Include="wwwroot\css\partials\_buttons.scss" /> - <Content Include="wwwroot\css\Site.scss" /> - <Content Include="wwwroot\css\_base.scss" /> - <Content Include="wwwroot\images\cool-alex.jpg" /> - <Content Include="wwwroot\images\icons\coffee-mug.svg" /> - <Content Include="wwwroot\images\icons\glass-shot.svg" /> - <Content Include="wwwroot\images\icons\meeple.svg" /> - <Content Include="wwwroot\images\icons\rolling-dices.svg" /> - <Content Include="wwwroot\js\highlight.min.js" /> - </ItemGroup>
However, it probably is worth noting. This error occurred further times (including, as a way of entertainment, as I deployed this article) as I had added more items to my project. I resolved it the same way, by unloading the project and editing the file manually. Hopefully this is just a blip and ironed out in a future Visual Studio update.