Can not build application for Android (.Net 7) - c#

At first Visual Studio said me to restore workloads, but when I tried it I always got an error. After changing versions number in C:\Program Files\dotnet\sdk-manifests\7.0.100\ I finally restored workloads. After it I got the following error on build:
Unable to find package Microsoft.Maui.Essentials.Ref.android with version (=52.1.0)
Unable to find package Microsoft.Maui.Essentials.Runtime.android with version (=52.1.0)
error on build
Errors full text:
Error NU1102 Unable to find package Microsoft.Maui.Essentials.Ref.android with version (= 52.1.0)
- Found 31 version(s) in nuget.org [ Nearest version: 7.0.59 ]
- Found 0 version(s) in Microsoft Visual Studio Offline Packages
- Found 0 version(s) in C:\Program Files\dotnet\library-packs
Error NU1102 Unable to find package Microsoft.Maui.Essentials.Runtime.android with version (= 52.1.0)
- Found 31 version(s) in nuget.org [ Nearest version: 7.0.59 ]
- Found 0 version(s) in Microsoft Visual Studio Offline Packages
- Found 0 version(s) in C:\Program Files\dotnet\library-packs
How to fix it?

Fix it by changing version number in C:\Program Files\dotnet\sdk-manifests\7.0.100\microsoft.net.sdk.maui from 51.1.0 to 7.0.59

Related

Why is MSBuild looking at incorrect path?

I have been trying to build a .NET project with visual studio 2017 Community on my local.
The build works fine when done using Publish option but throws below error when trying using msbuild
C:\Users\ajay3\source\repos\Triyo.API\TriyoCore.API>msbuild
Microsoft (R) Build Engine version 4.8.4084.0
[Microsoft .NET Framework, version 4.0.30319.42000]
Copyright (C) Microsoft Corporation. All rights reserved.
Build started 2021-06-28 3:55:47 PM.
Project "C:\Users\ajay3\source\repos\Triyo.API\TriyoCore.API\TriyoCore.API.csproj" on node 1 (default targets).
C:\Users\ajay3\source\repos\Triyo.API\TriyoCore.API\TriyoCore.API.csproj(281,3): error MSB4019: The imported project "C:\Program Files (x86)\MSBuild\Microsoft\VisualSt
udio\**v11.0**\WebApplications\Microsoft.WebApplication.targets" was not found. Confirm that the path in the <Import> declaration is correct, and that the file exists on disk.
Done Building Project "C:\Users\ajay3\source\repos\Triyo.API\TriyoCore.API\TriyoCore.API.csproj" (default targets) -- FAILED.
Build FAILED.
"C:\Users\ajay3\source\repos\Triyo.API\TriyoCore.API\TriyoCore.API.csproj" (default target) (1) ->
C:\Users\ajay3\source\repos\Triyo.API\TriyoCore.API\TriyoCore.API.csproj(281,3): error MSB4019: The imported project "C:\Program Files (x86)\MSBuild\Microsoft\Visual
Studio\**v11.0**\WebApplications\Microsoft.WebApplication.targets" was not found. Confirm that the path in the <Import> declaration is correct, and that the file exists on
disk.
0 Warning(s)
1 Error(s)
Time Elapsed 00:00:00.08
I have gone through various similar articles on Stackoverflow and various other sites but none of them help.
Where it is pulling v11.0 from? I don't have that value in my csproj file.
Are you using correct version of MSBuild?
C:\Windows\Microsoft.NET\Framework\v4.0.30319\MSBuild.exe
C:\Windows\Microsoft.NET\Framework\v2.0.50727\MSBuild.exe
C:\Windows\Microsoft.NET\Framework64\v4.0.30319\MSBuild.exe
C:\Windows\Microsoft.NET\Framework64\v2.0.50727\MSBuild.exe
The path to MSBuild could be different depending on your pc
If Yes check the following example
C:\Windows\Microsoft.NET\Framework\v4.0.30319\MSBuild.exe C:\Users\ajay3\source\repos\Triyo.API\TriyoCore.API\TriyoCore.API.csproj /t:Clean
For more information run the following command:
C:\Windows\Microsoft.NET\Framework\v4.0.30319\MSBuild.exe /?
You can also use this link
I cleaned up my system and reinstalled msbuild and it works fine now.

Microsoft.Typescript was not imported by Microsoft.NET.Sdk.Web.ProjectSystem

I am using VS Community Studio 2019 to build a new web page with ASP.NET. Upon creating new RESTful API templates, I receive this kind of error:
Project "C:\Program Files (x86)\Microsoft Visual Studio\2019\Community\MSBuild\Microsoft\VisualStudio\v16.0\TypeScript\Microsoft.TypeScript.targets" was not imported by "C:\Program Files\dotnet\sdk\3.1.200\Sdks\Microsoft.NET.Sdk.Web.ProjectSystem\targets\Microsoft.NET.Sdk.Web.ProjectSystem.targets" at (14,3), due to the file being invalid
It is also an issue for Microsoft.Typescript.Default.props and Microsoft.TypeScript.DotNetCore.targets, leading to an error (I guess) :Root element is missing.
Is there any solution for it?
For the same error in my case this worked :
1 - Go to NuGet packages manager
2 - Install this package : Microsoft.TypesCript.MSBuild
Regards
After reinstalling the TypeScript SDK, the error became an warning: "This is most likely a build authoring error. This subsequent import will be ignored."

VS 2015 Toolset may be unknown or missing

I try to publish project to my file directory.
I take a this message. But do not shown any error. Error list is empyty.
2> Building with tools version "14.0".
2> Project file contains ToolsVersion="12.0". This toolset may be
unknown or missing, in which case you may be able to resolve this by
installing the appropriate version of MSBuild, or the build may have
been forced to a particular ToolsVersion for policy reasons. Treating
the project as if it had ToolsVersion="14.0". For more information,
please see http://go.microsoft.com/fwlink/?LinkId=293424. 2> Target
"ValidateMSBuildToolsVersion" skipped. Previously built
unsuccessfully. 2>Done building project "project_name.csproj" – FAILED. 2>
========== Build: 1 succeeded, 0 failed, 0 up-to-date, 0 skipped ==========
========== Publish: 0 succeeded, 1 failed, 0 skipped ==========
VS 2015 Toolset may be unknown or missing
According to the error message "Project file contains ToolsVersion="12.0". ", it shows that your project was upgraded from Visual Studio 2013. So when you publish it with Visual Studio 2015, you may get this error "This toolset may be unknown or missing..."
To resolve this issue, you can try to update your project file: Right your project->Unload project->Edit Yourprojectname.csproj->change the ToolsVersion="12.0" to ToolsVersion="14.0" in the second line.
<?xml version="1.0" encoding="utf-8"?>
<Project ToolsVersion="12.0" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
If you are using MSBuild command line build your project, you can can override the ToolsVersion Settings of Projects and Solutions by using command prompt:
msbuild.exe someproj.proj /tv:14.0
Why don't you try changing the version of the "Microsoft.Net.Compilers" from from v2.6.1 to v2.4.0 as per explained here

MSBuild restore target - MSB4057: The target "restore" does not exist in the project

We have over 20 solutions in our main product portfolio (over 880 projects), and we have a complex set of build scripts that work well, but we are trying to automate the restore of nuget packages from within the msbuild pipeline. Currently this is done with a manual call out to nuget to restore the packages.
According to https://learn.microsoft.com/en-us/nuget/schema/msbuild-targets I should be able to run this command and have the restore run:
# works
& $script:msBuildPath $solutionName /t:build /v:q /clp:ErrorsOnly /nologo /p:...
# doesn't works
& $script:msBuildPath $solutionName /t:restore,build /v:q /clp:ErrorsOnly /nologo /p:...
However, when I add the restore, to the above it throws an error
MSB4057: The target "restore" does not exist in the project
Where do I start researching to understand why it can't find this target? We are predominantly on VS 2015 and .NET 4.6.2, so anything specific to VS2017 is not an option for me at this time.
If I omit the /v:q and /clp:ErrorsOnly flags I do get this (slightly sanitized solution/project names and paths)
PS Z:\git\company> build c
building Common\Common.sln
Build started 11/15/2017 11:08:54 AM.
1>Project "Z:\git\company\Common\Common.sln" on node 1 (restore;build target(s)).
1>ValidateSolutionConfiguration:
Building solution configuration "DEBUG|Any CPU".
1>Z:\git\company\Common\Common.sln.metaproj : error MSB4057: The target "restore" does not exist in the project. [Z:\git\company\Common\Common.sln]
1>Done Building Project "Z:\git\company\Common\Common.sln" (restore;build target(s)) -- FAILED.
Build FAILED.
"Z:\git\company\Common\Common.sln" (restore;build target) (1) ->
Z:\git\company\Common\Common.sln.metaproj : error MSB4057: The target "restore" does not exist in the project. [Z:\git\company\Common\Common.sln]
0 Warning(s)
1 Error(s)
Time Elapsed 00:00:00.03
runBuildPackage : ... failed
At Z:\git\company\psincludes\buildFunctions.ps1:11 char:5
+ runBuildPackage "Common\Common.sln"
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+ CategoryInfo : NotSpecified: (:) [Write-Error], WriteErrorException
+ FullyQualifiedErrorId : Microsoft.PowerShell.Commands.WriteErrorException,runBuildPackage
msbuild failed
At Z:\git\company\psincludes\buildInternals.ps1:63 char:21
+ throw "msbuild failed";
+ ~~~~~~~~~~~~~~~~~~~~~~
+ CategoryInfo : OperationStopped: (msbuild failed:String) [], RuntimeException
+ FullyQualifiedErrorId : msbuild failed
I realize some of this around is our internal tooling, I just didn't feel the need to obscure that part.
According to "the internet" this should just be "free" as part of the build process, and I'm not sure what we are missing in the csproj files here.
The msbuild-integrated NuGet functionality is available in NuGet 4.0+ in conjunction with MSBuild 15, which means only in VS 2017. There is no support for the restore target for VS 2015.
The integrated restore in VS 2017 / NuGet 4 only works for projects using the new PackageReference style of referencing NuGet packages. It does not work for projects using packages.config. This new way of referencing packages is the default option for ASP.NET Core (both on .NET Framework / .NET Core), .NET Core and .NET Standard projects. It is opt-in for all other project types by selecting the style before the first install in the NuGet properties (Tools->Options->NuGet).
Note that calling /t:Restore,Build is not a good way to call this target, since restore may generate or change files that msbuild then doesn't reload. MSBuild 15.5 (upcoming update to VS 2017) introduces a /restore option instead that will call the restore target, then clear all caches which could not be cleared before and execute the normal build as requested. Before 15.5, it is best to make two distinct calls to msbuild.

Azure Service Fabric unable to do CI on VSTS with ASP.NET Core

I have Service Fabric based system created and working on production environment (and development). Everything is ok. Now I was trying to setup CI on Visual Studio Team Services with provided templates for ASF projects.
Unfortunately my system has Actors (.NET 4.5.2) and WebAPI based on ASP.NET Core 1.1. I have references to Actor interfaces project (also .NET 4.5.2) forom .NET Core.
When I'm trying to build project with default template I'm recieving error because dotnet restore was not run. Ok, so I've added step to run dotnet restore but then I'm getting error complaining that it cannot find reference to Actor.Interfaces.
dotnet restore also fails on my dev machine but solution build with VS goes ok.
How can I fix this issue?
[UPDATE]
Thanks Mardoxx, I've made some progress... now I'm getting below error for *.sln buld. My solution is VS2015 (set in build task), I've set env to Hosted VS2017.
IntegrationApi\IntegrationApi.xproj(7,11): Error MSB4226: The imported project "C:\Program Files (x86)\Microsoft Visual Studio\2017\Enterprise\MSBuild\Microsoft\VisualStudio\v15.0\DotNet\Microsoft.DotNet.Props" was not found. Also, tried to find "DotNet\Microsoft.DotNet.Props" in the fallback search path(s) for $(VSToolsPath) - "C:\Program Files (x86)\MSBuild\Microsoft\VisualStudio\v15.0" . These search paths are defined in "C:\Program Files (x86)\Microsoft Visual Studio\2017\Enterprise\MSBuild\15.0\Bin\amd64\msbuild.exe.Config". Confirm that the path in the <Import> declaration is correct, and that the file exists on disk in one of the search paths.
Project "d:\a\1\s\Labelcall.sln" (1) is building "d:\a\1\s\IntegrationApi\IntegrationApi.xproj" (18) on node 1 (default targets).
d:\a\1\s\IntegrationApi\IntegrationApi.xproj(7,11): error MSB4226: The imported project "C:\Program Files (x86)\Microsoft Visual Studio\2017\Enterprise\MSBuild\Microsoft\VisualStudio\v15.0\DotNet\Microsoft.DotNet.Props" was not found. Also, tried to find "DotNet\Microsoft.DotNet.Props" in the fallback search path(s) for $(VSToolsPath) - "C:\Program Files (x86)\MSBuild\Microsoft\VisualStudio\v15.0" . These search paths are defined in "C:\Program Files (x86)\Microsoft Visual Studio\2017\Enterprise\MSBuild\15.0\Bin\amd64\msbuild.exe.Config". Confirm that the path in the <Import> declaration is correct, and that the file exists on disk in one of the search paths.
Done Building Project "d:\a\1\s\IntegrationApi\IntegrationApi.xproj" (default targets) -- FAILED.
[UPDATE2]
After taking steps presented by starain-MSFT I'm getting errors during 'dotnet restore':
log : Restoring packages for d:\a\1\s\AdminPanel\project.json...
error: Unable to resolve 'AccountActor.Interfaces' for
'.NETFramework,Version=v4.5.2'.
error: Unable to resolve 'CommonContracts' for
'.NETFramework,Version=v4.5.2'.
error: Unable to resolve 'CommonInfrastructure' for
'.NETFramework,Version=v4.5.2'.
[UPDATE3]
Another update after #starain input.
Now I'm getting error that references (to .NET 4.5.2 projcects from Core projects) could not be found.
Project "d:\a\1\s\LabelcallApplication\LabelcallApplication.sfproj" (2) is building "d:\a\1\s\MobileApi\MobileApi.xproj" (19) on node 1 (default targets).
PrepareForBuild:
Creating directory ".\bin\".
Creating directory ".\obj\Release\".
PreComputeCompileTypeScript:
C:\Program Files (x86)\Microsoft SDKs\TypeScript\2.0\tsc.exe --noEmitOnError --listEmittedFiles
CompileTypeScript:
C:\Program Files (x86)\Microsoft SDKs\TypeScript\2.0\tsc.exe --noEmitOnError --listEmittedFiles
CoreCompile:
C:\Program Files\dotnet\dotnet.exe build "d:\a\1\s\MobileApi" --configuration Release --no-dependencies
Project MobileApi (.NETFramework,Version=v4.5.2) will be compiled because expected outputs are missing
Compiling MobileApi for .NETFramework,Version=v4.5.2
C:\Program Files\dotnet\dotnet.exe compile-csc #d:\a\1\s\MobileApi\obj\Release\net452\dotnet-compile.rsp returned Exit Code 1
MobileApi\project.json(6,44): Warning NU1012: Dependency conflict. Microsoft.ApplicationInsights.DependencyCollector 2.2.0 expected Microsoft.ApplicationInsights 2.2.0 but received 2.3.0
d:\a\1\s\MobileApi\project.json(6,44): warning NU1012: Dependency conflict. Microsoft.ApplicationInsights.DependencyCollector 2.2.0 expected Microsoft.ApplicationInsights 2.2.0 but received 2.3.0 [d:\a\1\s\MobileApi\MobileApi.xproj]
MobileApi\project.json(6,44): Warning NU1012: Dependency conflict. Microsoft.ApplicationInsights.PerfCounterCollector 2.2.0 expected Microsoft.ApplicationInsights 2.2.0 but received 2.3.0
d:\a\1\s\MobileApi\project.json(6,44): warning NU1012: Dependency conflict. Microsoft.ApplicationInsights.PerfCounterCollector 2.2.0 expected Microsoft.ApplicationInsights 2.2.0 but received 2.3.0 [d:\a\1\s\MobileApi\MobileApi.xproj]
MobileApi\project.json(6,44): Warning NU1012: Dependency conflict. Microsoft.ApplicationInsights.WindowsServer.TelemetryChannel 2.2.0 expected Microsoft.ApplicationInsights 2.2.0 but received 2.3.0
d:\a\1\s\MobileApi\project.json(6,44): warning NU1012: Dependency conflict. Microsoft.ApplicationInsights.WindowsServer.TelemetryChannel 2.2.0 expected Microsoft.ApplicationInsights 2.2.0 but received 2.3.0 [d:\a\1\s\MobileApi\MobileApi.xproj]
C:\Program Files (x86)\MSBuild\Microsoft\VisualStudio\v14.0\DotNet\Microsoft.DotNet.Common.Targets(262,5): Error : d:\a\1\s\MobileApi\error CS0006: Metadata file 'd:\a\1\s\ContactActor.Interfaces\bin\Release\ContactActor.Interfaces.dll' could not be found
C:\Program Files (x86)\MSBuild\Microsoft\VisualStudio\v14.0\DotNet\Microsoft.DotNet.Common.Targets(262,5): error : d:\a\1\s\MobileApi\error CS0006: Metadata file 'd:\a\1\s\ContactActor.Interfaces\bin\Release\ContactActor.Interfaces.dll' could not be found [d:\a\1\s\MobileApi\MobileApi.xproj]
C:\Program Files (x86)\MSBuild\Microsoft\VisualStudio\v14.0\DotNet\Microsoft.DotNet.Common.Targets(262,5): Error : d:\a\1\s\MobileApi\error CS0006: Metadata file 'd:\a\1\s\DeviceActor.Interfaces\bin\Release\DeviceActor.Interfaces.dll' could not be found
C:\Program Files (x86)\MSBuild\Microsoft\VisualStudio\v14.0\DotNet\Microsoft.DotNet.Common.Targets(262,5): error : d:\a\1\s\MobileApi\error CS0006: Metadata file 'd:\a\1\s\DeviceActor.Interfaces\bin\Release\DeviceActor.Interfaces.dll' could not be found [d:\a\1\s\MobileApi\MobileApi.xproj]
Compilation failed.
3 Warning(s)
2 Error(s)
Time elapsed 00:00:01.7675632
Refer to these steps below:
Create a new build definition with Azure Service Fabric Application template
Change Visual Studio Version to Visual Studio 2015 for Visual Studio Build steps.
Select NuGet Installer step/task, change NuGet version to 3.5.0 in Advanced section.
Select Options tab and change Default agent queue to Hosted
Queue build with Hosted agent. (Not Hosted VS 2017)
All build steps:
NuGet Installer (NuGet restore ***.sln)
.Net Core (dotnet restore)
Visual Studio Build (Build solution ***.sln)
Visual Studio Build (Build solution ***.sfproj)
Copy Files
Delete files
Update Service Fabric App Versions
Copy Files
Publish Build Artifacts

Categories