Ionic 2.3.2 [CordovaApp.Windows10.jsproj(61,5): error MSB4019] - visual-studio

When I run ionic build windows i get the below error
Building project: D:\app-Name\platforms\windows\CordovaApp.Windows10.jsproj
Configuration : debug
Platform : x64
D:\app-Name\platforms\windows\CordovaApp.Windows10.jsproj(61,5): error MSB4019: The imported project "C:\Program Files (x86)\MSBuild\Microsoft\VisualStudio\v14.0\Microsoft.VisualStudio..Default.prop" was not found.
Confirm that the path in the <Import> declaration is correct, and that the file exists on disk.
Error: C:\Program Files (x86)\MSBuild\14.0\bin\msbuild.exe: Command failed with exit code 1
My system info [ionic info]
Cordova CLI: 7.0.1
Ionic Framework Version: 2.0.0-beta.10
Ionic CLI Version: 2.2.3
Ionic App Lib Version: 2.2.1
ios-deploy version: Not installed
ios-sim version: Not installed
OS: Windows 10
Node Version: v6.10.2
Xcode version: Not installed
I have installed Visual Studio community edition 2017 along with specific 2015 and 2017 build tools including the SDK.
Added the min target preferences in config.xml. Even after everything i'm unable to build it.
Please help me to resolve this issue.

It seems that Cordova looks for MSBuild tools version 14 of Visual Studio 2015.
These release notes suggest setting the environment variable MSBUILDDIR to the correct MSBuild directory installed on your system:
Install MSBuild tools 2015: https://www.microsoft.com/en-za/download/details.aspx?id=48159
Set environment variable MSBUILDDIR to C:\Program Files (x86)\MSBuild\14.0\Bin

Related

dotnet build not finding Xamarin

When running dotnet build in my project, I have the following error:
/path/to/repo/Toolkit/My.Company.Toolkit.Platform.Android/My.Company.Toolkit.Platform.Android.csproj(91,3): error MSB4019: The imported project "/usr/local/share/dotnet/sdk/7.0.102/Xamarin/Android/Xamarin.Android.CSharp.targets" was not found. Confirm that the expression in the Import declaration "/usr/local/share/dotnet/sdk/7.0.102//Xamarin/Android/Xamarin.Android.CSharp.targets" is correct, and that the file exists on disk.
/path/to/repo/Toolkit/My.Company.Toolkit.Platform.iOS/My.Company.Toolkit.Platform.iOS.csproj(195,3): error MSB4019: The imported project "/usr/local/share/dotnet/sdk/7.0.102/Xamarin/iOS/Xamarin.iOS.CSharp.targets" was not found. Confirm that the expression in the Import declaration "/usr/local/share/dotnet/sdk/7.0.102//Xamarin/iOS/Xamarin.iOS.CSharp.targets" is correct, and that the file exists on disk.
I confirm that /usr/local/share/dotnet/sdk/7.0.102/Xamarin/iOS/Xamarin.iOS.CSharp.targets does not exist.
But I don't know how to install it there.
The reference to Xamarin is defined in the csproj like this <Import Project="$(MSBuildExtensionsPath)\Xamarin\Android\Xamarin.Android.CSharp.targets" />.
When I build from Visual Studio I have no issues. And if I try to re-install Xamarin, it says it is already installed.
I am on MacOS.
[UPDATE]
I uninstalled everything (Visual Studio, SDKs/Runtime, dotnet, etc).
Installed just Visual Studio 2022 for Mac.
➜ ~ dotnet --info
.NET SDK:
Version: 7.0.102
Commit: 4bbdd14480
Runtime Environment:
OS Name: Mac OS X
OS Version: 13.1
OS Platform: Darwin
RID: osx.13-arm64
Base Path: /usr/local/share/dotnet/sdk/7.0.102/
Host:
Version: 7.0.2
Architecture: arm64
Commit: d037e070eb
.NET SDKs installed:
6.0.405 [/usr/local/share/dotnet/sdk]
7.0.102 [/usr/local/share/dotnet/sdk]
.NET runtimes installed:
Microsoft.AspNetCore.App 6.0.13 [/usr/local/share/dotnet/shared/Microsoft.AspNetCore.App]
Microsoft.AspNetCore.App 7.0.2 [/usr/local/share/dotnet/shared/Microsoft.AspNetCore.App]
Microsoft.NETCore.App 6.0.13 [/usr/local/share/dotnet/shared/Microsoft.NETCore.App]
Microsoft.NETCore.App 7.0.2 [/usr/local/share/dotnet/shared/Microsoft.NETCore.App]
Other architectures found:
None
Environment variables:
Not set
global.json file:
Not found
Learn more:
https://aka.ms/dotnet/info
Download .NET:
https://aka.ms/dotnet/download
Now if I try to build the project in the terminal I still have the same error. But if I try to build it from Visual Studio I have a different error.
I have this error in the build output
Target RazorGenerateComponentDeclaration:
/usr/local/share/dotnet/dotnet exec "/Users/redacted/Library/Caches/VisualStudio/17.0/MSBuild/36265_3/Sdks/Microsoft.NET.Sdk.Razor/build/netstandard2.0/../../tools/netcoreapp3.0/rzc.dll" generate
-s
/Users/redacted/Developer/repositories/bcee/Toolkit/MyCompany.Toolkit.Platform.Web/_Imports.razor
-r
_Imports.razor
-o
/Users/redacted/Developer/repositories/bcee/Toolkit/MyCompany.Toolkit.Platform.Web/obj/Debug/netstandard2.1/RazorDeclaration/_Imports.razor.g.cs
-k
component
-p
/Users/redacted/Developer/repositories/bcee/Toolkit/MyCompany.Toolkit.Platform.Web
-t
obj/Debug/netstandard2.1/MyCompany.Toolkit.Platform.Web.RazorComponents.declaration.json
-v
3.0
-c
Default
--root-namespace
MyCompany.Toolkit.Web
--csharp-language-version
8.0
--generate-declaration
The application to execute does not exist: '/Users/redacted/Library/Caches/VisualStudio/17.0/MSBuild/36265_3/Sdks/Microsoft.NET.Sdk.Razor/build/netstandard2.0/../../tools/netcoreapp3.0/rzc.dll'
/Users/redacted/Library/Caches/VisualStudio/17.0/MSBuild/36265_3/Sdks/Microsoft.NET.Sdk.Razor/build/netstandard2.0/Microsoft.NET.Sdk.Razor.Component.targets(106,5): error : rzc generate exited with code 129.
Done building target "RazorGenerateComponentDeclaration" in project "MyCompany.Toolkit.Platform.Web.csproj" -- FAILED.
Done building project "MyCompany.Toolkit.Platform.Web.csproj" -- FAILED.
Build FAILED.
The tools directory does not exists.
At fisrt, you said:
When I build from Visual Studio I have no issues.
The cause should be when you build from the Visual Studio. The framework your project used is .netstandard 2.0. You can check the project.csproj file and the SDK in the /usr/local/share/dotnet/sdk.
In addition, you can check this case which has the similar error as yours. According to it, if the .net version is not compatible with the xamarin will also get this error. dotnet/sdk/7.0.102 should be the .net 7 which is compatible with the .net maui not the xamarin. So you can't use the dotnet build the project.
You can try to find the right value of the MSBuildExtensionsPath and set it in the android and ios .csproj file according to this case which is about set the project's MSBuildExtensionsPath.
Finally, you can try the solution in this case which has the same error message.
The Xamarin tool chain was built upon Mono, so everything you triggered in VS for Mac is kindly processed by MSBuild for Mono (at Mac terminal you can use msbuild --version to learn more).
dotnet build, however, was designed exclusively for .NET Core based projects, so by default it won't be able to handle Xamarin projects, but only .NET MAUI.
As legacy Xamarin projects are going away soon, you should start to migrate to MAUI as soon as you can,
https://dotnet.microsoft.com/en-us/platform/support/policy/xamarin

Cordova, building for android can not find gradle on Windows 10

Installed Cordova 10 through npm on Windows 10, and I have installed:
The correct Java JDK
Android Studio
In Android Studio => Settings menu, I have added SDK's for all the Android versions from 7 to 11 (API Level 24 to 30)
I have added environment variables to location of Android Studio in Path (... \Appdata\Local\Android\SDK)
I have added the ANDROID_SDK_ROOT and ANDROID_HOME environment variables to same location as above
I have downloaded gradle 6.7.1 and added D:\gradle-6.7.1 to both Path and GRADLE_HOME environment variable
Still(!) I can not manage to build a basic apk from Cordova sample build, getting the following message:
Checking Java JDK and Android SDK versions
ANDROID_SDK_ROOT=C:\Users\XXX\AppData\Local\Android\Sdk (recommended setting)
ANDROID_HOME=C:\Users\XXX\AppData\Local\Android\Sdk (DEPRECATED)
Using Android SDK: C:\Users\XXX\AppData\Local\Android\Sdk
Could not find an installed version of Gradle either in Android Studio,
or on your system to install the gradle wrapper. Please include gradle
in your path, or install Android Studio
Had to add \bin to the gradle directory in Path environment variable, finally it works.

Flutter windows app compile cmake error $<TARGET_FILE_DIR:testbed>

I'm actually trying to build a flutter app windows but i got this error message :
flutter build windows
CMake Error:
Error evaluating generator expression:
$<TARGET_FILE_DIR:testbed>
No target "testbed"
CMake Generate step failed. Build files cannot be regenerated correctly.
Building Windows application...
Unable to generate build files
The error was repeated about 20 times.
There is no problem with the flutter doctor -v command :
[√] Visual Studio - develop for Windows (Visual Studio Community 2019 16.6.3)
• Visual Studio at C:\Program Files (x86)\Microsoft Visual Studio\2019\Community
• Visual Studio Community 2019 version 16.6.30225.117
• Windows 10 SDK version 10.0.18362.0
If anyone have a solution, thanks to him.
I found where the error came from :
In the .\build\windows\CMakeCache.txt file at line 59 there is this :CMAKE_INSTALL_PREFIX:PATH=$<TARGET_FILE_DIR:testbed>
To solve my error i just need to replace testbed by my project name.
Just go build folder in your flutter project and delete the windows folder and everything will be back to normal

Why can't Visual Studio 2017 find installed .NET Core SDKs?

I have a simple project which builds with "dotnet build" and with msbuild from the Visual Studio 2019 Developer prompt, but not from the Visual Studio 2017 prompt or IDE. I would like to understand how msbuild 15 finds the installed SDKs and why they are not up to date, while msbuild 16 in VS 2019 works ok.
It appears that the .NET Core SDKs are not registered with msbuild 15 but I don't know how that registration occurs. I have tried reinstalling the SDK, installing different versions of the SDK, but no luck so far.
Unfortunately just switching to 2019 is difficult because what I really want is to compile a large code base with a build script which assumes 2017 - this is a cut-down repro.
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<OutputType>Exe</OutputType>
<TargetFramework>netcoreapp2.0</TargetFramework>
</PropertyGroup>
</Project>
Compiling from VS2017 developer prompt:
msbuild foo.csproj /nologo
Build started 5/20/2019 7:22:06 AM.
Project "C:\Users\edwin\Source\Repos\foo\foo.csproj" on node 1 (default targets).
C:\Program Files (x86)\Microsoft Visual Studio\2017\Community\MSBuild\Sdks\Microsoft.NET.Sdk\build\Microsoft.NET.TargetFrame
workInference.targets(112,5): error : The current .NET SDK does not support targeting .NET Core 2.0. Either target .NET Cor
e 1.1 or lower, or use a version of the .NET SDK that supports .NET Core 2.0. [C:\Users\edwin\Source\Repos\foo\foo.csproj]
Done Building Project "C:\Users\edwin\Source\Repos\foo\foo.csproj" (default targets) -- FAILED.
Compiling in same window with "dotnet build" succeeds, as does "msbuild foo.csproj" in the 2019 developer prompt (which uses msbuild 16).
dotnet --info shows
.NET Core SDK (reflecting any global.json):
Version: 2.2.204
Commit: 8757db13ec
Runtime Environment:
OS Name: Windows
OS Version: 10.0.17763
OS Platform: Windows
RID: win10-x64
Base Path: C:\Program Files\dotnet\sdk\2.2.204\
Host (useful for support):
Version: 2.2.5
Commit: 0a3c9209c0
.NET Core SDKs installed:
1.0.3 [C:\Program Files\dotnet\sdk]
2.1.104 [C:\Program Files\dotnet\sdk]
2.1.202 [C:\Program Files\dotnet\sdk]
2.1.402 [C:\Program Files\dotnet\sdk]
2.1.403 [C:\Program Files\dotnet\sdk]
2.1.604 [C:\Program Files\dotnet\sdk]
2.2.204 [C:\Program Files\dotnet\sdk]
I experienced this issue 4 days ago when I was using Visual Studio 2017. And I spent all the days to solve it. After searching, on internet,I realised that it was a versioning issue.
verytime, I tried to create a new project I had this message:
The SDK 'Microsoft.NET.Sdk.Web' specified could not be found.
So, I decided to delete all the .Net Core SDK versions and installed the compatible one as indicated on the download Page. See the image below.
[
After installing it, everything started working fine.

Ionic cordova build windows throw *MSBUILD* error

When i run ionic cordova build windows it throws error like-
> cordova build windows
ENV var MSBUILDDIR is set C:\Program Files (x86)\Microsoft Visual Studio\2017\Enterprise
Building project: C:\Users\shail\Desktop\ionic-demo\ionic-4-windows\platforms\windows\CordovaApp.Windows10.jsproj
Configuration : debug
Platform : anycpu
Buildflags : /p:AppxBundle=Never
MSBuildTools : C:\Program Files (x86)\MSBuild\14.0\bin
buildProject spawn: C:\Program Files (x86)\MSBuild\14.0\bin\msbuild [ 'C:\\Users\\shail\\Desktop\\ionic-demo\\ionic-4-windows\\platforms\\windows\\CordovaApp.Windows10.jsproj',
'/clp:NoSummary;NoItemAndPropertyList;Verbosity=minimal',
'/nologo', '/p:Configuration=debug', '/p:Platform=anycpu', '/p:AppxBundle=Never'] { stdio: 'inherit' } C:\Users\shail\Desktop\ionic-demo\ionic-4-windows\platforms\windows\CordovaApp.Windows10.jsproj(61,5): error MSB4019: The imported project "C:\Program Files(x86)\MSBuild\Microsoft\VisualStudio\v14.0\Microsoft.VisualStudio..Default.props" was not found. Confirm that the path in the <Import> declaration is correct, and that the file exists on disk.
No valid MSBuild was detected for the selected target: Error: C:\Program Files (x86)\MSBuild\14.0\bin\msbuild: Command failed with exit code 1
is any one can help to resolve this problem.
ionic -v is 4.12.0
cordove -v is 9.0.0
installed platform
cordova platforn list
Installed platforms:
android 8.0.0
windows 7.0.0
Using Visual Studio 2017 Enterprise
According to the error message: The path of your msbuild tool is
invalid.
1.As for vs2017, the msbuild you use should be C:\Program Files (x86)\Microsoft Visual Studio\2017\Enterprise\MSBuild\15.0\Bin instead of C:\Program Files (x86)\MSBuild\14.0\bin.
2.Also, v14.0 is for vs2015 while v15.0 for vs2017, please change all 'v14.0' in your setting to 'v15.0' and run it.

Resources