I recently upgraded to Visual Studio Community 2019 16.5.2. Our Blazor Server application’s solution comprises of several projects and all of them are targeted to .NET Core 3.1
When I am trying to publish my application from Visual Studio, I get the below error:
NU1201 Project GCB.Storage is not compatible with netcoreapp3.0 (.NETCoreApp,Version=v3.0) / win-x64. Project GCB.Storage supports: netcoreapp3.1 (.NETCoreApp,Version=v3.1)
Visual Studio says I get above error for project "GCB.Main" in GCB.Main.csproj. GCB.Main has a reference to the project GCB.Storage. Both of these projects’ target framework is set to .NET Core 3.1. I double checked all the dependencies and project references in both the projects and none of them depend on .NET Core 3.0
Microsoft documentation says that error might occur when "A dependency project doesn't contain a framework compatible with the current project. Typically, the project's target framework is a higher version than the consuming project."
Here are my publishing profile parameters in Visual Studio:
Configuration: Debug
Target framework: netcoreapp3.1
Deployment mode: Framework-Dependent
Target runtime: win-x64
I looked at control panel on the server where I am publishing and it has "Microsoft .NET Core SDK 3.1.201 (x64) from Visual Studio" update installed. Do I need to configure/install anything on the server? I do not see an entry for .NET Core Runtime 3.1 but I do see entries for MSFT .NET Core - 3.0.0 (x86), one for x64, and one for MSFT .NET Core 3.0.0 - Windows Server Hosting. Should I install .NET Core 3.1 runtime explicitly even though I installed Visual Studio 2019 16.5.2 on the same server?
Please note that I am able to compile/rebuild the solution without any errors on the same server where I am publishing it to. However when I try to publish I get above publishing errors.
Below is my pubxml
--
<Project ToolsVersion="4.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<PropertyGroup>
<WebPublishMethod>FileSystem</WebPublishMethod>
<PublishProvider>FileSystem</PublishProvider>
<LastUsedBuildConfiguration>Debug</LastUsedBuildConfiguration>
<LastUsedPlatform>Any CPU</LastUsedPlatform>
<SiteUrlToLaunchAfterPublish />
<LaunchSiteAfterPublish>True</LaunchSiteAfterPublish>
<ExcludeApp_Data>False</ExcludeApp_Data>
<TargetFramework>netcoreapp3.0</TargetFramework>
<RuntimeIdentifier>win-x64</RuntimeIdentifier>
<ProjectGuid>a2939d6d-c286-40c3-a015-e946d67cd806</ProjectGuid>
<SelfContained>false</SelfContained>
<publishUrl>C:\GCB</publishUrl>
<DeleteExistingFiles>True</DeleteExistingFiles>
</PropertyGroup>
</Project>
--
Any pointers?
Thanks
It looks like the publishing profile is out of sync with the UX for whatever reason.
Update your pubxml file to <TargetFramework>netcoreapp3.1</TargetFramework> and it should publish without issues
Related
I have a project which made by asp.net core 2.1, and now I wanna to migrate to the 2.2 version.
I installed the SDK of 2.2 and changed the target framework to 2.2 in properties of the project.
After I clean&rebuild the solution, there are some warnings here I can not clean it:
1.
2.
3.
I found a tutorial about this which provided by Microsoft:
https://learn.microsoft.com/en-us/aspnet/core/migration/21-to-22?view=aspnetcore-2.2&tabs=visual-studio
I tried but still no work.
I think updating the new version SDK is easier like the .net framework by just changes the target framework in properties of the project. However, it seems not.
I wonder if there have an official tool which to update the .net core SDK from 2.1 to 2.2. Or I'd better create a brand new 2.2 project as well as paste all the file into it rather than fix the troublesome warnings.
Thank you.
Okay, so I found an easier solution than to renew the entire project. What I did was
Made sure those two lines exist in my project file.
<PropertyGroup>
<TargetFramework>netcoreapp2.2</TargetFramework>
<RuntimeFrameworkVersion>2.2.0</RuntimeFrameworkVersion>
</PropertyGroup>
Then I had errors saying that some of the packages were not compatible, so I changed the versions of those as well. It was those two specifically:
<ItemGroup>
<PackageReference Include="Microsoft.AspNetCore.Razor.Design" Version="2.2.0" PrivateAssets="All" />
<PackageReference Include="Microsoft.AspNetCore.SpaServices.Extensions" Version="2.2.0" />
</ItemGroup>
After that everything compiled successfully without warnings.
Finally, I used the most stupid way that creates a brand new empty .net core 2.2 project and pastes most of the old project file(including the model/controllers/view/stylesheet/javascript but except the csproj/Properties)to it.
Then clear the solution and rebuild, all warning clear.
This way is so rude and unprofessional, but maybe is the easiest way to do it.
The schema errors may be an indicator that you are using an outdated Visual Studio 2017 edition.
To use .NET Core 2.2 you need to update to the latest Visual Studio 2017.9 (15.9).
Prerequisites for .NET Core on Windows:
To verify your Visual Studio version:
On the Help menu, choose About Microsoft Visual Studio.
In the About Microsoft Visual Studio dialog, verify the version number.
For .NET Core 3.0 Preview 1 apps, Visual Studio 2019 Preview 1 or higher.
For .NET Core 2.2 apps, Visual Studio 2017 version 15.9 or higher.
For .NET Core 2.1 apps, Visual Studio 2017 version 15.7 or higher.
For .NET Core 1.x apps, Visual Studio 2017 version 15.0 or higher.
The new core 2 directory services are described here https://learn.microsoft.com/en-gb/dotnet/api/system.directoryservices?view=netcore-2.0
I have Visual Studio 2017 and the Core 2 SDK installed but can't reference the newly added directory services, how do I install these?
Can't find them in object browser.
Using PMC install-package System.DirectoryServices gives me v4.0
<ItemGroup>
<PackageReference Include="System.DirectoryServices" Version="4.0.0" />
</ItemGroup>
and the following warning
Package 'System.DirectoryServices 4.0.0' was restored using '.NETFramework,Version=v4.6.1' instead of the project target framework '.NETCoreApp,Version=v2.0'. This package may not be fully compatible with your project.
Using 'manage packages' only shows the unsupported version by bmars.
Any ideas?
Thanks,
Andy
Microsoft has a MyGet feed that has a preview package of System.DirectoryServices which should be able to work with ASP.NET Core 2.0
https://dotnet.myget.org/feed/dotnet-core/package/nuget/System.DirectoryServices
Based on documentation https://learn.microsoft.com/en-us/nuget/schema/msbuild-targets, it looks like msbuild now support 2 specific targets for NuGet: Pack and Restore.
I have been able to use Restore properly, but not Pack.
error MSB4057: The target "Pack" does not exist in the project.
Is it supported for traditional .Net project or is it a .Net Core thing only?
I haven't been able to find any documentation stating it clearly.
Regarding required dependencies, I am using
PM> nuget help
NuGet Version: 4.1.0.2450
usage: NuGet <command> [args] [options]
Type 'NuGet help <command>' for help on a specific command.
And
C:\Git>msbuild /version
Microsoft (R) Build Engine version 15.1.1012.6693
Copyright (C) Microsoft Corporation. All rights reserved.
15.1.1012.6693
With
Microsoft Visual Studio Professional 2017
Version 15.2 (26430.12) Release
VisualStudio.15.Release/15.2.0+26430.12
Microsoft .NET Framework
Version 4.6.01586
It is supported out of the box for "SDK-based" projects. There is no project template in VS for .NET Framework libraries using this ""new-style csproj"", but you can create a .NET Standard library project and manually change the TargetFramework property in the csproj file from netstandard1.6 to net461. Note that the project system that is used for these types of project doesn't support many features available in classic .net projects yet (like designers for WinForms, Xaml, edmx).
The resulting project file would look like this:
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<TargetFramework>net461</TargetFramework>
</PropertyGroup>
</Project>
Looks like I did not Google enough... this blog post clearly speaks about .Net Core only: http://blog.nuget.org/20170316/NuGet-now-fully-integrated-into-MSBuild.html
Some of the features discussed earlier are not yet fully supported for
packages.config based projects such as defining nuspec metadata in
project files, building packages directly from a project, [...]. We are hard at work to bring full PackageReference support to
these project types. Our goal is to eventually make PackageReference
the default and move away from all other formats.
I am trying to deploy an Asp.net Core app to my shared host. Apparently, the server is only compatible with NetCore.App v1.03 or v.1.1.0, not the latest versions v1.0.4/v1.1.1 respectively. In Visual Studio, Im trying to publish to target framework "netcoreapp1.0" but I am only able to access NetCore.App v1.04 from Nuget. Nuget states that other versions including v1.0.3 are blocked by the project.
Can anyone tell me how to tell Visual Studio to use v1.0.3 for my project instead of v1.0.4?
Apart from installing the missing versions on the server, you can add this manually to a <PropertyGroup> element of your csproj file:
<RuntimeFrameworkVersion>1.0.3</RuntimeFrameworkVersion>
I created an ASP.NET core application with Visual Studio and the .NET core tools. It runs fine on Windows, but when I copy it to Ubuntu for deployment and then run it, I get:
....xproj(7,3): error MSB4019: The imported project "/usr/share/dotnet/sdk/1.0.0-preview4-004233/Microsoft/VisualStudio/v14.0/DotNet/Microsoft.DotNet.Props" was not found.
Which makes sense, because Visual Studio isn't installed on Ubuntu. Why is it there? I tried removing the import from the xproj and that causes other problems:
error MSB4057: The target "Build" does not exist in the project.
Here's the xproj
<?xml version="1.0" encoding="utf-8"?>
<Project ToolsVersion="14.0" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<PropertyGroup>
<VisualStudioVersion Condition="'$(VisualStudioVersion)' == ''">14.0</VisualStudioVersion>
<VSToolsPath Condition="'$(VSToolsPath)' == ''">$(MSBuildExtensionsPath32)\Microsoft\VisualStudio\v$(VisualStudioVersion)</VSToolsPath>
</PropertyGroup>
<Import Project="$(VSToolsPath)\DotNet\Microsoft.DotNet.Props" Condition="'$(VSToolsPath)' != ''" />
<PropertyGroup Label="Globals">
<ProjectGuid>ca453b3a-1bb5-4ed8-bbe5-fe1e627a9f76</ProjectGuid>
<RootNamespace>abc</RootNamespace>
<BaseIntermediateOutputPath Condition="'$(BaseIntermediateOutputPath)'=='' ">.\obj</BaseIntermediateOutputPath>
<OutputPath Condition="'$(OutputPath)'=='' ">.\bin\</OutputPath>
<TargetFrameworkVersion>v4.5.2</TargetFrameworkVersion>
</PropertyGroup>
<PropertyGroup>
<SchemaVersion>2.0</SchemaVersion>
</PropertyGroup>
<Import Project="$(VSToolsPath)\DotNet.Web\Microsoft.DotNet.Web.targets" Condition="'$(VSToolsPath)' != ''" />
</Project>
I'm new to ASP.NET core, and currently lost in a sea of versions, tools, previews... I think the VS tools targets 1.0.0, but when I installed dotnet core on linux I got 1.1.0, so I also installed 1.0.0 and use
dotnet run --framework 1.0.0
What am I supposed to be doing to create a web project in VS (2015) and deploy it to linux?
UPDATE from further googling I found (https://github.com/aspnet/EntityFramework/issues/5420) that I should install ".NET Core Tooling Preview 1 for Visual Studio 2015", but I can't do that because I'm on linux, so what should I do?
Is it not possible to develop a web app in VS and deploy to linux?
UPDATE 2
Ok, so despite everything I'm reading saying that you run a web app with dotnet run, I found here that I should use dotnet myDLL.dll (and that works, on Windows at least I haven't tried on Linux yet)
So what's the reason? Core versions?
dotnet run is much better than having to know the correct DLL name, so I'm guessing dotnet run is for v1.1? Have I somehow built my project for v1.0?
I am lost with all the versioning and previews etc etc, I'd appreciate a explanation. I thought I was downloading the latest stuff, and I thought the VS toolkit was version agnostic?
I am a bit confused about the .xproj file on your Linux machine. If you publish your web app locally you should not see an .xproj file in between the published files. Because .xproj is only a file Visual Studio needs. Dotnet core only needs a project.json file and a void static main to function.
1) Try the guide in this link https://learn.microsoft.com/en-us/aspnet/core/publishing/linuxproduction
2) Or follow the guidelines from Scott Hanselman's post: http://www.hanselman.com/blog/PublishingAnASPNETCoreWebsiteToACheapLinuxVMHost.aspx
I found out that the correct way to do it (for SDK 1.0.0) is
Publish from VS
Copy content of publish output folder to Linux
Run it with dotnet myapp.dll (instead of dotnet run).