Renaming namespace in Java Bindings Library Project - Generator error - xamarin

Following the directions at http://developer.xamarin.com/guides/android/advanced_topics/java_integration_overview/binding_a_java_library_(.jar)/api_metadata_reference/#Metadata.xml_Transform_File
<attr path="/api/package[#name='com.mycompany.myapi]" name="managedName">MyCompany.MyAPI</attr>
In this example, a Java library with a package
com.mycompany.myapi is mapped to the .NET namespace MyCompany.MyAPI.
I am trying to rename the namespace of a binding library project I created. The project successfully compiles before trying to do any transformations. Looking at the generated obj/debug/api.xml file the first few lines show
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<api>
<package name="android_serialport">
...
So to change the namespace from android_serialport to something like MyCompany.Ports.IO I am editing Transofrms/Metadata.xml to be
<metadata>
<attr path="/api/package[#name='android_serialport]" name="managedName">MyCompany.Ports.IO</attr>
</metadata>
However, with this added line I get an error that is rather cryptic:
C:\Program Files (x86)\MSBuild\Xamarin\Android\Xamarin.Android.Bindings.targets(5,5): Error MSB6006: "generator.exe" exited with code -532462766. (MSB6006) (SerialPort)
The library I'm trying to create bindings to is was created in Android Studio to generate an aar. Without the transformation line added, everything compiles and I am able to reference it with no problem.
Anyone have experience with binding library transformations failing?

The error message is coming from the bindings generator. I was unable to find any docs on the error code, but it's being thrown due to a typo in the edited Transforms/Metadata.xml file:
path="/api/package[#name='android_serialport]"
should be
path="/api/package[#name='android_serialport']"
Notice the missing ' at the end of the #name. It's too bad the error message doesn't lead you to this.

Related

Error MSB4061: The "XamlCTask" task could not be instantiated

While trying to compile a Xamarin Forms (2.3.4.247) project on Visual Studio for Mac Community (7.0.1 [build 24]) I keep getting the two following errors after coding some time, any clue on what caused it and how to fix it?
/Users/PathToProjectRoot/packages/Xamarin.Forms.2.3.4.247/build/portable-win+net45+wp80+win81+wpa81+MonoAndroid10+Xamarin.iOS10+xamarinmac20/Xamarin.Forms.targets(3,3): Error MSB4061: The "XamlCTask" task could not be instantiated from "/Users/PathToProjectRoot/packages/Xamarin.Forms.2.3.4.247/build/portable-win+net45+wp80+win81+wpa81+MonoAndroid10+Xamarin.iOS10+xamarinmac20/Xamarin.Forms.Build.Tasks.dll". Could not load file or assembly 'Xamarin.Forms.Build.Tasks' or one of its dependencies (MSB4061) (ProjectName)
/Users/PathToProjectRoot/packages/Xamarin.Forms.2.3.4.247/build/portable-win+net45+wp80+win81+wpa81+MonoAndroid10+Xamarin.iOS10+xamarinmac20/Xamarin.Forms.targets(3,3): Error MSB4060: The "XamlCTask" task has been declared or used incorrectly, or failed during construction. Check the spelling of the task name and the assembly name. (MSB4060) (ProjectName)
What I have tried
Updated all packages and and SDKs.
Cleaned/Rebuild solution.
Removed all packages, closed VS, reopened and got all packages restored.
Removed all the bin and obj folders to try a rebuild.
Check the 3 .csproj for any outdated imports previous to 2.3.4.247.
Create a new solution.
What has worked
Creating a new clean solution using Xamarin Forms works however this causes all the packages to be from an old version. I've already done this twice but I'd like to be able to stop doing this as it takes a crazy amount of time to transfer all files from the broken project to the new one.
What hasn't worked
Besides all the things I've tried, it may be useful to mention that creating a new project after having cleared all the previous ones within the same solution doesn't fix the issue.
This makes me think that it is a solution-level error rather than a project-level error.
What packages are installed
Xamarin.Android.Support.Animated.Vector.Drawable.25.3.1
Xamarin.Android.Support.Annotations.25.3.1
Xamarin.Android.Support.Compat.25.3.1
Xamarin.Android.Support.Core.UI.25.3.1
Xamarin.Android.Support.Core.Utils.25.3.1
Xamarin.Android.Support.Design.25.3.1
Xamarin.Android.Support.Fragment.25.3.1
Xamarin.Android.Support.Media.Compat.25.3.1
Xamarin.Android.Support.Transition.25.3.1
Xamarin.Android.Support.Vector.Drawable.25.3.1
Xamarin.Android.Support.v4.25.3.1
Xamarin.Android.Support.v7.AppCompat.25.3.1
Xamarin.Android.Support.v7.CardView.25.3.1
Xamarin.Android.Support.v7.MediaRouter.25.3.1
Xamarin.Android.Support.v7.Palette.25.3.1
Xamarin.Android.Support.v7.RecyclerView.25.3.1
Xamarin.Build.Download.0.4.5
Xamarin.Forms.2.3.4.247
What Android platforms are installed
android-23
android-25
What file causes the errors
Error is caused by the file Xamarin.Forms.targets containing the following lines:
<Project xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<UsingTask TaskName="Xamarin.Forms.Build.Tasks.XamlGTask" AssemblyFile="Xamarin.Forms.Build.Tasks.dll"/>
<UsingTask TaskName="Xamarin.Forms.Build.Tasks.FixedCreateCSharpManifestResourceName" AssemblyFile="Xamarin.Forms.Build.Tasks.dll"/>
<UsingTask TaskName="Xamarin.Forms.Build.Tasks.XamlCTask" AssemblyFile="Xamarin.Forms.Build.Tasks.dll"/>
<!-- Some more lines here ... -->
<Target Name="XamlC">
<!-- /!\ Error flagged at next line's "<" -->
<XamlCTask
Assembly = "$(IntermediateOutputPath)$(TargetFileName)"
ReferencePath = "#(ReferencePath)"
Verbosity = "2"
OptimizeIL = "true"
DebugSymbols = "$(DebugSymbols)"
DebugType = "$(DebugType)"/>
</Target>
</Project>
Latest updates
[June 16]
After trying to create a new solution several times, I'm now unable to create one that's able to build. Whatever version my packages are on, I keep getting those two errors.
See the Build output here.
This issue was caused by the # character within the project's path. Removing it resolved the issue.
Wired ... But closing visual studio and reopen solved the problem in my case
I had the same issue, it was caused by C:\User\name\.nuget folder being a symbolic link (created with MKLINK), which pointed to a directory on a bigger drive. When I set NUGET_PACKAGE environment variable to the actual location of the package directory, the issue is solved.
I was facing a similar issue like yours. I updated many dependencies and removed a few.
I'm using this version of VS
I tried all the answers and didn't work.
I followed the "Just In Case" approach (mentioned in this answer thread previously.) of killing the VS instance and reopening it. Then when I executed the project all errors vanished.
In my case, I didnt have # in the path and I tried clean and rebuild,deleting obj,bin,packages folders, closed and opened many times etc but didnt work.
My nuget packages folder is referenced at this path 'C:/Users/xyz/.nuget/packages/'
I tried to change the path of this nuget packages folder using a nuget.config file and placed it in the solution folder as specified in the below link and it worked.
Is it possible to change the location of packages for NuGet?
For me this piece of code worked among all the answers in the above link.
<?xml version="1.0" encoding="utf-8"?>
<configuration>
<config>
<add key="globalPackagesFolder" value="C:\Projects\MyProj\.nuget\packages" />
<add key="repositoryPath" value="C:\Projects\MyProj\.nuget\packages" />
</config>
</configuration>

JAR Bindings Library issue

I am trying to generate java binding library for this java project material-camera (https://github.com/afollestad/material-camera) the jar files are available on https://dl.bintray.com/drummer-aidan/maven/com/afollestad/material-camera/0.4.4/
unfortunately, the dll is empty, can someone please help me here?
Trying to bind that .aar myself, I got one error initially:
Error CS0234: The type or namespace name 'ICameraUriInterface' does not exist in the namespace 'Com.Afollestad.Materialcamera.Internal'. Are you missing an assembly reference? (CS0234) (MaterialCamera)
Looking in the jar, I see that the java interface CameraUriInterface is private, so I changed it to public by adding the following to the MetaData.xml file:
<attr path="/api/package[#name='com.afollestad.materialcamera.internal']/interface[#name='CameraUriInterface']" name="visibility">public</attr>
Add the above line between the <metatdata> </metadata> tags. After adding the above the binding built without error and a .dll was created.

What is creating these files with a jmconfig extension?

I've got multiple Visual Studio projects and solutions that have a .jmconfig file in the root directory for the project or the solution. I only noticed that the file shows up when checking my project into source control and it tells me that the .jmconfig is new.
Here is a sample:
<?xml version="1.0" encoding="utf-8"?><Configuration xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema"><DontShowAgainInSolution>false</DontShowAgainInSolution></Configuration>
This is JustMock trying to save some settings so that you don't get reminded to upgrade all the time.

Error: The element <ParameterGroup> beneath element <UsingTask> is unrecognized

I am receiving this error, when building the solution using the msbuild.
The element <ParameterGroup> beneath element <UsingTask> is
unrecognized.
The error is showing both in msbuild and in Visual Studio.
This is because one of your project is targeting .NET 3.5.
All of your projects should be targeted to .NET 4.0 at least.
If your .cs project does not allow to view or change the Target Framework, as it was in my situation: You will need to change it manually in .csproj.
Open the .csproj in notepad.
In this line
<Project ToolsVersion="3.5"...
change the ToolsVersion to at least 4.0.
Other possibility, is that you are using <UsingTask> inside a <Target> element.
You MUST declare it outside the <Target />.
Tested on 2017 and 2019.
The error is the following otherwise. (I would bet this is #Crono sees with Roslyn).
proj(2300,5): error MSB4067: L'élément "ParameterGroup" situé sous l'élément <UsingTask> n'est pas reconnu.
Just copy the config below and create a specflow.exe.config file
Put this config file next to your specflow.exe and you will be able to create the nunitexecutionreport report.
also can use this link https://github.com/techtalk/SpecFlow/wiki/Reporting
<?xml version="1.0" encoding="utf-8" ?>
<configuration>
<startup>
<supportedRuntime version="v4.0.30319" />
</startup>
</configuration>

Cannot load WiX projects after installing the VS2010 Web Publishing Updates

I installed the VS2010 web publishing updates yesterday, and now whenever I try to load a WiX setup project (all showing as unloaded in solution explorer) I'm getting the error:
The imported project "PROJECTNAME.wpp.targets" was not found. Confirm that the path in the declaration is correct, and that the file exists on disk. C:\Program Files\MSBuild\Microsoft\VisualStudio\v10.5\Web\Microsoft.Web.Publishing.targets
Where PROJECTNAME is the path to my setup wixproj file, without the .wixproj extension. I've checked through the project file and there is no reference to a wpp.targets file anywhere. I decided to try and create a blank targets file in that location and so added one with just this in it:
<Project ToolsVersion="4.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
</Project>
But got exactly the same error - a not found exception despite the file being there!
I then dug into the Microsoft.Web.Publishing.targets file and had a look for any ".wpp.targets" text, which gave me this:
<PropertyGroup Condition="'$(EnableWebPublishProfileFile)'=='true' And
'$(WebPublishProfileFile)' != '' And Exists($(WebPublishProfileFile)) ">
<WebPublishProfileCustomizeTargetFile Condition="'$(WebPublishProfileCustomizeTargetFile)'==''">
$([System.IO.Path]::ChangeExtension($(WebPublishProfileFile), '.wpp.targets'))
</WebPublishProfileCustomizeTargetFile>
...
So that looks to be setting up a filename of PROJECTNAME.wpp.targets, but only when the EnableWebPublishProfileFile property is set to true. I added this to my wixproj file's main propertygroup:
<EnableWebPublishProfileFile>False</EnableWebPublishProfileFile>
Again though, it made no difference at all to the error. I'm running out of ideas here now!
Further update
I've been trying to repo this on a blank project (so far without success), and the messing about has narrowed the error down to this line (186) in the Microsoft.Web.Publishing.targets file:
<Import Project="$(WebPublishPipelineCustomizeTargetFile)"
Condition="'$(WebPublishPipelineCustomizeTargetFile)' != ''"/>
This is set at the top of the file:
<WebPublishPipelineCustomizeTargetFile
Condition="'$(WebPublishPipelineCustomizeTargetFile)'==''">
$(WebPublishPipelineProjectDirectory)\*.wpp.targets
</WebPublishPipelineCustomizeTargetFile>
I'm not sure how this is getting changed to PROJECTNAME.wpp.targets though?
I tried overriding this in my project file, but once again, it makes no difference at all.
Next I added an Exists() condition to the line in the targets file, now some projects are working and others are not, instead failing (on build) with the error:
The "DisableEscapeMSBuildVariable" parameter is not supported by the "ImportParametersFile" task. Verify the parameter exists on the task, and it is a settable public instance property.
My journey continues...
I experienced the same issue when trying to open a standard web project.
The proj file was referencing the following import for v10.0 targets but throwing the import error in the question which referred to v10.5 targets.
<Import Project="$(MSBuildExtensionsPath)\Microsoft\VisualStudio\v10.0\Web\Microsoft.Web.Publishing.targets" />
The same was true when I referenced a hard coded path - I still got v10.5 error
My solution was to simply back up and remove that version located at:
C:\Program Files (x86)\MSBuild\Microsoft\VisualStudio\10.5
I'm really not sure what other programs and projects need this version or why import paths were not followed but it go this project open for me seeming falling back to the correct version.

Resources