ASP Core migration 1.1 to 2.0 : Controller/Views scaffolding multiple exceptions - scaffolding

I migrate my asp core 1.1 project to 2.0 with success, I can build, and launch debug with no problem.
But when using the scaffolding to generates Controllers and Views (VS Community 2017)
Add > Add Scaffolded item > MVC Controller with views, using Entity Framework
I've got several exceptions when launching the process on any POCO, as example I picked the first thrown exception
=> I changed the default templates to match my pattern (ie DI of generic Service Layer within each controller) and on the project before migration (on asp core 1.1) everything worked fine.
There was an error running the template C:\Users\Nicolas\Documents\Visual Studio
2017\Projects\WebPortal\WebPortal\Templates\ControllerGenerator\MvcControllerWithContext.cshtml: Template Processing
Failed:Template(45,31): error CS0246: The type or namespace name 'List<>' could not be found (are you missing a using
directive or an assembly reference?) Template(65,33): error CS0246: The type or namespace name 'Dictionary<,>' could
not be found (are you missing a using directive or an assembly reference?) Template(118,28): error CS0246: The type or
namespace name 'List<>' could not be found (are you missing a using directive or an assembly reference?) at
Microsoft.VisualStudio.Web.CodeGeneration.ActionInvoker.<BuildCommandLine>b__6_0() at
Microsoft.Extensions.CommandLineUtils.CommandLineApplication.Execute(String[] args) at
Microsoft.VisualStudio.Web.CodeGeneration.ActionInvoker.Execute(String[] args) at
Microsoft.VisualStudio.Web.CodeGeneration.CodeGenCommand.Execute(String[] args)
And the concerned lines of my Controller template sued for the scaffold:
var modelProperties = new List(); (line 45)
var relatedProperties = new Dictionary<string, dynamic>(); (line 65)
var dependencies = new List(); (line 118)
Obviously I import the corresponding namespace for List and Dictionary.
If I remove these lines I've got other exceptions which were not thrown when the project was on .net core 1.1 version.
Here is the .csproj for 2.0 project (scaffolding fails)
<Project Sdk="Microsoft.NET.Sdk.Web">
<PropertyGroup>
<TargetFramework>netcoreapp2.0</TargetFramework>
</PropertyGroup>
<PropertyGroup>
<AssetTargetFallback>$(AssetTargetFallback);portable-net45+win8+wp8+wpa81;</AssetTargetFallback>
</PropertyGroup>
<PropertyGroup>
<UserSecretsId>aspnet-WebPortal-ed2c59f1-3859-46e1-af11-xxxxx</UserSecretsId>
<PackageTargetFallback>portable-net45+win8</PackageTargetFallback>
</PropertyGroup>
<ItemGroup>
<PackageReference Include="Microsoft.AspNetCore" Version="2.0.0" />
<PackageReference Include="Microsoft.AspNetCore.All" Version="2.0.0" />
<PackageReference Include="Microsoft.AspNetCore.Mvc" Version="2.0.0" />
<PackageReference Include="Microsoft.AspNetCore.StaticFiles" Version="2.0.0" />
<PackageReference Include="Microsoft.EntityFrameworkCore.Design" Version="2.0.0" />
<PackageReference Include="Microsoft.EntityFrameworkCore.SqlServer" Version="2.0.0" />
<PackageReference Include="Microsoft.EntityFrameworkCore.SqlServer.Design" Version="1.1.2" />
<PackageReference Include="Microsoft.EntityFrameworkCore.Tools" Version="2.0.0" />
<PackageReference Include="Microsoft.Extensions.Logging.Debug" Version="2.0.0" />
<PackageReference Include="Microsoft.VisualStudio.Web.BrowserLink" Version="2.0.0" />
<PackageReference Include="Microsoft.VisualStudio.Web.CodeGeneration.Design" Version="2.0.0" />
</ItemGroup>
<ItemGroup>
<DotNetCliToolReference Include="Microsoft.EntityFrameworkCore.Tools.DotNet" Version="2.0.0" />
<DotNetCliToolReference Include="Microsoft.Extensions.SecretManager.Tools" Version="2.0.0" />
<DotNetCliToolReference Include="Microsoft.VisualStudio.Web.CodeGeneration.Tools" Version="2.0.0" />
</ItemGroup>
</Project>
And the .csproj for 1.1 project (scaffolding works with same template)
<Project Sdk="Microsoft.NET.Sdk.Web">
<PropertyGroup>
<TargetFramework>netcoreapp1.1</TargetFramework>
</PropertyGroup>
<PropertyGroup>
<PackageTargetFallback>$(PackageTargetFallback);portable-net45+win8+wp8+wpa81;</PackageTargetFallback>
</PropertyGroup>
<PropertyGroup>
<UserSecretsId>aspnet-WebPortal-ed2c59f1-3859-46e1-af11-xxxxx</UserSecretsId>
</PropertyGroup>
<ItemGroup>
<PackageReference Include="Microsoft.ApplicationInsights.AspNetCore" Version="2.0.0" />
<PackageReference Include="Microsoft.AspNetCore" Version="1.1.2" />
<PackageReference Include="Microsoft.AspNetCore.Authentication.Cookies" Version="1.1.2" />
<PackageReference Include="Microsoft.AspNetCore.Diagnostics.EntityFrameworkCore" Version="1.1.2" />
<PackageReference Include="Microsoft.AspNetCore.Identity.EntityFrameworkCore" Version="1.1.2" />
<PackageReference Include="Microsoft.AspNetCore.Mvc" Version="1.1.3" />
<PackageReference Include="Microsoft.AspNetCore.StaticFiles" Version="1.1.2" />
<PackageReference Include="Microsoft.EntityFrameworkCore.Design" Version="1.1.2" PrivateAssets="All" />
<PackageReference Include="Microsoft.EntityFrameworkCore.SqlServer" Version="1.1.2" />
<PackageReference Include="Microsoft.EntityFrameworkCore.SqlServer.Design" Version="1.1.2" PrivateAssets="All" />
<PackageReference Include="Microsoft.EntityFrameworkCore.Tools" Version="1.1.1" PrivateAssets="All" />
<PackageReference Include="Microsoft.Extensions.Configuration.UserSecrets" Version="1.1.2" />
<PackageReference Include="Microsoft.Extensions.Logging.Debug" Version="1.1.2" />
<PackageReference Include="Microsoft.VisualStudio.Web.CodeGeneration.Design" Version="1.1.1" PrivateAssets="All" />
<PackageReference Include="Microsoft.VisualStudio.Web.BrowserLink" Version="1.1.2" />
</ItemGroup>
<ItemGroup>
<DotNetCliToolReference Include="Microsoft.EntityFrameworkCore.Tools.DotNet" Version="1.0.0" />
<DotNetCliToolReference Include="Microsoft.Extensions.SecretManager.Tools" Version="1.0.0" />
<DotNetCliToolReference Include="Microsoft.VisualStudio.Web.CodeGeneration.Tools" Version="1.0.0" />
</ItemGroup>
</Project>
Anyone could help on that point ? I can supply the templates off course.
Regards

I finally managed to make my template works on .net core 2.0, I checked the differences between my templates and the templates from the repo Templates Github repo, and here are the mandatory modifications :
Templates\ControllerGenerator\MvcControllerWithContext.cshtml
Add :
#using System.Collections.Generic;
#using System.Linq;
in addition of :
using System.Collections.Generic;
using System.Linq;
So the 'header' looks like :
#inherits Microsoft.VisualStudio.Web.CodeGeneration.Templating.RazorTemplateBase
#using System.Collections.Generic;
#using System.Linq;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Threading.Tasks;
using Microsoft.AspNetCore.Mvc;
using Microsoft.AspNetCore.Mvc.Rendering;
using Microsoft.EntityFrameworkCore;
Templates\ViewGenerator\List.cshtml
Add :
#using System.Collections.Generic;
#using System.Linq;
so the 'header' looks like :
#inherits Microsoft.VisualStudio.Web.CodeGeneration.Templating.RazorTemplateBase
#using Microsoft.VisualStudio.Web.CodeGeneration.EntityFrameworkCore
#using System.Collections.Generic
#using System.Linq
##model #getenumerabletypeexpression(Model.ViewDataTypeName)
Then make the following replacement :
IEnumerable<PropertyMetadata> properties = Model.ModelMetadata.Properties;
replaced by
var properties = Model.ModelMetadata.Properties;
I didn't have to change anything else to my other view templates, and I don't use other controller templates

Related

IWebHostEnvironment .Net 5 not found

I am using .Net 5 class library project and here are my refrences. I am using
using Microsoft.AspNetCore.Hosting; But I cannot find IWebHostEnvironment. What wrong am I doing ?
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<TargetFramework>net5.0</TargetFramework>
</PropertyGroup>
<ItemGroup>
<PackageReference Include="Microsoft.AspNetCore.Hosting.Abstractions" Version="2.2.0" />
<PackageReference Include="Microsoft.AspNetCore.Http" Version="2.2.2" />
<PackageReference Include="Microsoft.AspNetCore.Http.Abstractions" Version="2.2.0" />
<PackageReference Include="Microsoft.Azure.DocumentDB.Core" Version="2.12.0" />
<PackageReference Include="Microsoft.EntityFrameworkCore" Version="5.0.0" />
<PackageReference Include="Microsoft.Extensions.Caching.Memory" Version="5.0.0" />
<PackageReference Include="Microsoft.Graph" Version="3.19.0" />
<PackageReference Include="Microsoft.Graph.Core" Version="1.22.0" />
<PackageReference Include="Microsoft.IdentityModel.Clients.ActiveDirectory" Version="5.2.8" />
<PackageReference Include="Microsoft.ReportViewer.WebForms" Version="10.0.40219.1" />
<PackageReference Include="Newtonsoft.Json" Version="12.0.3" />
<PackageReference Include="System.Data.SqlClient" Version="4.8.2" />
<PackageReference Include="System.Runtime" Version="4.3.1" />
<PackageReference Include="System.Runtime.CompilerServices.Unsafe" Version="4.5.2" />
<PackageReference Include="System.ServiceModel.Http" Version="4.8.1" />
<PackageReference Include="System.ServiceModel.Primitives" Version="4.8.1" />
<PackageReference Include="WindowsAzure.Storage" Version="9.3.3" />
</ItemGroup>
<ItemGroup>
<Reference Include="System.ServiceModel" />
</ItemGroup>
<ItemGroup>
<WCFMetadata Include="Connected Services" />
</ItemGroup>
</Project>
On .Net5.0, IWebHostEnvironment has been replaced by IHostEnvironment
Make sure you have the package Microsoft.Extensions.Hosting installed and the following import on the top of the file.
using Microsoft.Extensions.Hosting;
More information can be seen at aspnetcore github discussion
IWebHostEnvironment is included in the Microsoft.AspNetCore.Hosting package, you simply need to add it as a reference to your project by right clicking on your project file and selecting 'Manage Nuget Packages' then searching for Microsoft.AspNetCore.Hosting and add it.
If you've already added it and it still isn't working, try cleaning your project.

How to exclude Microsoft.CodeAnalysis.* DLLs from publishing

I've written .NET Standard 2.1 library component that relies on Microsoft.AspNetCore.Mvc v2.2.0 package, which indirectly references Microsoft.CodeAnalysis.CSharp.dll, MicrosoftCode.Analysis.dll, and Microsoft.CodeAnalysis.Razor.dll. When I reference my component from .NET Core 3.1 app site and publish the site, Microsoft.CodeAnalysis.* dlls are also published. Is there a way to exclude Microsoft.CodeAnalysis.* dlls from being published? I don't need them for production.
Here are my references from .NET Standard 2.1 CSPROJ file:
<ItemGroup>
<PackageReference Include="Microsoft.AspNetCore.Cryptography.KeyDerivation" Version="3.1.8" />
<PackageReference Include="Microsoft.AspNetCore.DataProtection.Abstractions" Version="3.1.8" />
<PackageReference Include="Microsoft.AspNetCore.Http.Features" Version="3.1.8" />
<PackageReference Include="Microsoft.AspNetCore.JsonPatch" Version="3.1.8" />
<PackageReference Include="Microsoft.AspNetCore.Mvc" Version="2.2.0" />
<PackageReference Include="Microsoft.AspNetCore.Razor.Language" Version="3.1.8" />
<PackageReference Include="Microsoft.CodeAnalysis.FxCopAnalyzers" Version="3.3.0">
<PrivateAssets>all</PrivateAssets>
<IncludeAssets>runtime; build; native; contentfiles; analyzers</IncludeAssets>
</PackageReference>
<PackageReference Include="Microsoft.DotNet.PlatformAbstractions" Version="3.1.6" />
<PackageReference Include="Microsoft.EntityFrameworkCore" Version="3.1.8" />
<PackageReference Include="Microsoft.Extensions.DependencyModel" Version="3.1.6" />
<PackageReference Include="Microsoft.Extensions.Identity.Core" Version="3.1.8" />
<PackageReference Include="Newtonsoft.Json" Version="12.0.3" />
Thanks in advance!
It looks like the issue comes from referencing the AspNetCore packages directly.
If you can change your class library to target netcoreapp3.1 instead of netstandard, you can replace those by using a FrameworkReference instead. Note that FrameworkReference is only valid for assemblies targetting Net Core 3.x and up. Reference
:
<ItemGroup>
<FrameworkReference Include="Microsoft.AspNetCore.App" />
</ItemGroup>
Alternatively, if you need to support both netstandard and netcoreapp, you can use conditional references.
<!-- Framework reference for netcoreapp -->
<ItemGroup Condition=" '$(TargetFramework)' == 'netcoreapp3.1' ">
<FrameworkReference Include="Microsoft.AspNetCore.App" />
</ItemGroup>
<!-- Common dependencies -->
<ItemGroup>
<PackageReference Include="Microsoft.CodeAnalysis.FxCopAnalyzers" Version="3.3.0">
<PrivateAssets>all</PrivateAssets>
<IncludeAssets>runtime; build; native; contentfiles; analyzers</IncludeAssets>
</PackageReference>
<PackageReference Include="Microsoft.EntityFrameworkCore" Version="3.1.8" />
<PackageReference Include="Newtonsoft.Json" Version="12.0.3" />
</ItemGroup>
<!-- netstandard dependencies -->
<ItemGroup Condition=" '$(TargetFramework)' == 'netstandard2.0' ">
<PackageReference Include="Microsoft.AspNetCore.Cryptography.KeyDerivation" Version="3.1.8" />
<PackageReference Include="Microsoft.AspNetCore.DataProtection.Abstractions" Version="3.1.8" />
<PackageReference Include="Microsoft.AspNetCore.Http.Features" Version="3.1.8" />
<PackageReference Include="Microsoft.AspNetCore.JsonPatch" Version="3.1.8" />
<PackageReference Include="Microsoft.AspNetCore.Mvc" Version="2.2.0" />
<PackageReference Include="Microsoft.AspNetCore.Razor.Language" Version="3.1.8" />
<PackageReference Include="Microsoft.DotNet.PlatformAbstractions" Version="3.1.6" />
<PackageReference Include="Microsoft.Extensions.DependencyModel" Version="3.1.6" />
<PackageReference Include="Microsoft.Extensions.Identity.Core" Version="3.1.8" />
</ItemGroup>
Note that I had to guess which package references your package library need, so you'll need to adapt as needed

.csproj bug in Asp .NET Core MVC

I have wanted to create new table in my database (SQLite), so I created new Model and used it in ApplicationDbContext class like this:
public DbSet<AppUser> AppUsers { get; set; }
public DbSet<Report> Reports { get; set; }
Then executed the command later:
dotnet ef migrations add Report
I can see migration file.
In Startup.cs file I have:
services.AddDbContext<ApplicationDbContext>(options => options.UseSqlServer(connectionString));
services.AddDbContext<AppIdentityDbContext>(options => options.UseSqlServer(connectionString));
In EFRepository.cs:
public IQueryable<AppUser> AppUsers
=> ctx.AppUsers;
public IQueryable<Report> Reports => ctx.Reports;
After this somehow suddenly I received many errors connected with this file ( .csproj):
<Project Sdk="Microsoft.NET.Sdk.Web">
<PropertyGroup>
<TargetFramework>netcoreapp3.0</TargetFramework>
<AssemblyName>Mushrooms</AssemblyName>
<RootNamespace>Mushrooms</RootNamespace>
</PropertyGroup>
<ItemGroup>
<PackageReference Include="Microsoft.AspNetCore.Identity.EntityFrameworkCore" Version="3.0.0" />
<PackageReference Include="Microsoft.EntityFrameworkCore" Version="3.0.0" />
<PackageReference Include="Microsoft.EntityFrameworkCore.Design" Version="3.0.0">
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
<PrivateAssets>all</PrivateAssets>
</PackageReference>
<PackageReference Include="Microsoft.EntityFrameworkCore.SqlServer" Version="3.0.0" />
<PackageReference Include="Microsoft.EntityFrameworkCore.Tools" Version="3.0.0">
<PrivateAssets>all</PrivateAssets>
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
</PackageReference>
<PackageReference Include="Microsoft.Extensions.Logging.Debug" Version="3.0.0" />
<PackageReference Include="Microsoft.VisualStudio.Web.CodeGeneration.Design" Version="3.0.0" />
<PackageReference Include="Newtonsoft.Json" Version="12.0.2" />
</ItemGroup>
</Project>
I checked dotnet --info command, but I can't see incompatibility.
Three of the errors:
Invalid markup declaration '<'
Invalid markup declaration '
Invalid token "" at root level of document.
and many more in every line of this file.
This errors have occured when system was starting up.
I am using Asp .NET Core MVC 3.0.0.
Before this everything was working fine, any suggestions?
I try to create blank .net core 3.0 project and this csproj file is working fine
<Project Sdk="Microsoft.NET.Sdk.Web">
<PropertyGroup>
<TargetFramework>netcoreapp3.0</TargetFramework>
</PropertyGroup>
<ItemGroup>
<PackageReference Include="Microsoft.AspNetCore.Identity.EntityFrameworkCore" Version="3.1.0" />
</ItemGroup>
</Project>
Try to check your project extension file should be .csproj

Could not load file or assembly 'Microsoft.EntityFrameworkCore.SqlServer, Version=1.1.2.0 error on asp.net core 1.1.1

I upgraded to VS2017 15.3.3 but still working on an ASP.NET MVC Core 1.1.1 project with code first approach. When following this tutorial from official ASP.NET team (that is geared more towards ASP.NET Core 2.0) when I ran the following Package Manager command (from the tutorial) I was getting compatibility error (v2.0 vs v1.1):
Install-Package Microsoft.EntityFrameworkCore.SqlServer
So, I decided to add the -version 1.1.1 as a parameter to the above command as follows and it ran successfully:
Install-Package Microsoft.EntityFrameworkCore.SqlServer -version 1.1.1
I did the same for other two related PM commands in the above mentioned tutorial and everything ran fine. But now, when I run the following PM command I get the following error:
PM> add-migration MyFirstMigration -context BloggingContext
Error
Could not load file or assembly 'Microsoft.EntityFrameworkCore.SqlServer, Version=1.1.2.0
.csproj File
<Project Sdk="Microsoft.NET.Sdk.Web">
<PropertyGroup>
<TargetFramework>netcoreapp1.1</TargetFramework>
<PackageTargetFallback>$(PackageTargetFallback);portable-net45+win8+wp8+wpa81;</PackageTargetFallback>
<UserSecretsId>aspnet-MVC_IndvUserAccts_Test-B2520DA6-BE8D-42EE-806D-366F7C4C2E77</UserSecretsId>
</PropertyGroup>
<ItemGroup>
<PackageReference Include="Microsoft.ApplicationInsights.AspNetCore" Version="2.0.0" />
<PackageReference Include="Microsoft.AspNetCore" Version="1.1.2" />
<PackageReference Include="Microsoft.AspNetCore.Authentication.Cookies" Version="1.1.2" />
<PackageReference Include="Microsoft.AspNetCore.Diagnostics.EntityFrameworkCore" Version="1.1.2" />
<PackageReference Include="Microsoft.AspNetCore.Identity.EntityFrameworkCore" Version="1.1.2" />
<PackageReference Include="Microsoft.AspNetCore.Mvc" Version="1.1.3" />
<PackageReference Include="Microsoft.AspNetCore.StaticFiles" Version="1.1.2" />
<PackageReference Include="Microsoft.EntityFrameworkCore.Design" Version="1.1.2" PrivateAssets="All" />
<PackageReference Include="Microsoft.EntityFrameworkCore.SqlServer" Version="1.1.1" />
<PackageReference Include="Microsoft.EntityFrameworkCore.SqlServer.Design" Version="1.1.2" PrivateAssets="All" />
<PackageReference Include="Microsoft.EntityFrameworkCore.Tools" Version="1.1.1" PrivateAssets="All" />
<PackageReference Include="Microsoft.Extensions.Configuration.UserSecrets" Version="1.1.2" />
<PackageReference Include="Microsoft.Extensions.Logging.Debug" Version="1.1.2" />
<PackageReference Include="Microsoft.VisualStudio.Web.CodeGeneration.Design" Version="1.1.1" PrivateAssets="All" />
<PackageReference Include="Microsoft.VisualStudio.Web.BrowserLink" Version="1.1.2" />
</ItemGroup>
<ItemGroup>
<DotNetCliToolReference Include="Microsoft.EntityFrameworkCore.Tools.DotNet" Version="1.0.1" />
<DotNetCliToolReference Include="Microsoft.Extensions.SecretManager.Tools" Version="1.0.1" />
<DotNetCliToolReference Include="Microsoft.VisualStudio.Web.CodeGeneration.Tools" Version="1.0.1" />
</ItemGroup>
</Project>
<PackageReference Include="Microsoft.EntityFrameworkCore.SqlServer" Version="1.1.2" />
<PackageReference Include="Microsoft.EntityFrameworkCore.SqlServer.Design" Version="1.1.2" />
<PackageReference Include="Microsoft.EntityFrameworkCore.Tools" Version="1.1.1" PrivateAssets="All" />
DotNeCliReference
<DotNetCliToolReference Include="Microsoft.EntityFrameworkCore.Tools.DotNet" Version="1.0.1" />
<DotNetCliToolReference Include="Microsoft.Extensions.SecretManager.Tools" Version="1.0.1" />
<DotNetCliToolReference Include="Microsoft.VisualStudio.Web.CodeGeneration.Tools" Version="1.0.1" />
Recently I have faced the same issue at my office system what help me to solve the problem is:
dotnet remove package Microsoft.VisualStudio.Web.CodeGeneration.Design -(system assembly 2.2.1.0 which was causing the error)
dotnet add package Microsoft.VisualStudio.Web.CodeGeneration.Design --version 2.2.0 -the correct assemly (Target assembly that is needed to my project)

Can't Build aspnetcore app in VS 2017 RC

After installing the new VS 2017 RC I'm having issues with building my asnetcore app, here is the error that I am receiving:
MSB4131 The "FilesWritten" parameter is not supported by the
"GenerateRuntimeConfigurationFiles" task. Verify the parameter exists
on the task, and it is a gettable public instance property.
Here is my .csproj file:
<Project ToolsVersion="15.0" Sdk="Microsoft.NET.Sdk.Web">
<PropertyGroup>
<OutputType>Exe</OutputType>
<TargetFramework>net462</TargetFramework>
<PreserveCompilationContext>true</PreserveCompilationContext>
</PropertyGroup>
<PropertyGroup Condition="'$(TargetFramework)' == 'net462'">
<RuntimeIdentifier>win7-x64</RuntimeIdentifier>
</PropertyGroup>
<PropertyGroup>
<PackageTargetFallback>$(PackageTargetFallback);portable-net45+win8+wp8+wpa81;</PackageTargetFallback>
</PropertyGroup>
<PropertyGroup>
<UserSecretsId>aspnet-HobbyQuarters.Web-e309acfb-31ce-4333-a350-edb5d1c073d3</UserSecretsId>
</PropertyGroup>
<ItemGroup Condition="'$(TargetFramework)' == 'netcoreapp1.0'">
<PackageReference Include="Microsoft.NETCore.App">
<Version>1.0.1</Version>
</PackageReference>
<PackageReference Include="System.ComponentModel.Annotations" Version="4.3.0" />
</ItemGroup>
<ItemGroup>
<PackageReference Include="Microsoft.AspNetCore.Diagnostics" Version="1.1.0" />
<PackageReference Include="Microsoft.AspNetCore.Mvc" Version="1.1.0" />
<PackageReference Include="Microsoft.AspNetCore.Routing" Version="1.1.0" />
<PackageReference Include="Microsoft.AspNetCore.Server.IISIntegration" Version="1.1.0" />
<PackageReference Include="Microsoft.AspNetCore.Server.Kestrel" Version="1.1.0" />
<PackageReference Include="Microsoft.AspNetCore.StaticFiles" Version="1.1.0" />
<PackageReference Include="Microsoft.Extensions.Configuration.EnvironmentVariables" Version="1.1.0" />
<PackageReference Include="Microsoft.Extensions.Configuration.Json" Version="1.1.0" />
<PackageReference Include="Microsoft.Extensions.Logging" Version="1.1.0" />
<PackageReference Include="Microsoft.Extensions.Logging.Console" Version="1.1.0" />
<PackageReference Include="Microsoft.Extensions.Logging.Debug" Version="1.1.0" />
<PackageReference Include="Microsoft.Extensions.Options.ConfigurationExtensions" Version="1.1.0" />
<PackageReference Include="Microsoft.AspNetCore.Owin" Version="1.1.0" />
<PackageReference Include="Microsoft.VisualStudio.Web.BrowserLink.Loader" Version="14.1.0" />
<PackageReference Include="Nancy">
<Version>2.0.0-barneyrubble</Version>
</PackageReference>
</ItemGroup>
<ItemGroup>
<PackageReference Include="Microsoft.AspNetCore.Authentication.Cookies" Version="1.1.0" />
<PackageReference Include="Microsoft.AspNetCore.Diagnostics.EntityFrameworkCore" Version="1.1.0" />
<PackageReference Include="Microsoft.Extensions.Configuration.UserSecrets" Version="1.1.0" />
<PackageReference Include="Microsoft.VisualStudio.Web.CodeGeneration.Design" Version="1.0.0-msbuild2-final" />
</ItemGroup>
<ItemGroup>
<Reference Include="System" />
<Reference Include="System.Data" />
<Reference Include="System.Xml" />
<Reference Include="System.Xml.Linq" />
<Reference Include="Microsoft.CSharp" />
<Reference Include="System.ComponentModel.DataAnnotations" />
</ItemGroup>
<ItemGroup>
<DotNetCliToolReference Include="Microsoft.Extensions.SecretManager.Tools" Version="1.0.0-msbuild2-final" />
<DotNetCliToolReference Include="Microsoft.VisualStudio.Web.CodeGeneration.Tools" Version="1.0.0-msbuild2-final" />
</ItemGroup>
<ItemGroup>
<Folder Include="Tasks\" />
</ItemGroup>
</Project>
Launch Task Manager
end all existing MSBuild tasks.
Rebuild your project(s). it should work just fine.
Beside. your .csproj looks just fine to me; however, it looks like its setup to run in two different environment perhaps console and aspcore 1.0
So it looks like this was related to having multiple projects with different msbuild tools versions.
I had older projects that weren't using the new convention of referencing the tools: ToolsVersion="15.0" Sdk="Microsoft.NET.Sdk.Web"...
Once I changed them to use this convention everything started to work.