获取生成错误创建使用Xamarin扩展的Visual Studio 2015年preVIEW Android应用程序应用程序、错误、Visual、Xamarin

2023-09-06 11:05:32 作者:低八度°

我使用的是最近随着Xamarian工作室5.6.3(或5.6.2)扩展为Visual Studio发布的Visual Studio 2015年preVIEW。

在下载并安装所有必需的软件(全部顺利完成)的时间,我开始开发的VS2015P Android应用程序,但我创建空白Android应用程序每次,我得到这个错误,并没有错误code:

  

在MergeApkRecipelists任务没有给出所需的参数RecipeFiles的值。

解决方案

想通了这一点通过查看Xamarin的.targets文件。

短版

您可以:

创建一个Android C ++库项目和参考,从您的Xamarin的Andr​​oid项目

或的

注释掉导入可以在%ProgramFiles(x86)的%\的MSBuild \ Xamarin \机器人\ Xamarin.Android.Common.After.targets定义的元素。注意这将有可能禁止添加C ++项目引用Xamarin的Andr​​oid项目提供支持。

一旦你做其中的一个,你Xamarin的Andr​​oid项目应该建立并运行。

龙版

首先,请注意在VS的输出窗口中的错误:

C:\ Program Files文件(x86)\MSBuild\Xamarin\Android\Xamarin.Android.Common\ImportAfter\Microsoft.Cpp.Android.targets(54,9):错误MSB4044:在MergeApkRecipelists任务没有给出所需的参数RecipeFiles值

Visual Studio 2015 正式发布,已开放下载

在错误中提到的Microsoft.Cpp.Android.targets文件看起来是所有关于配套项目引用到C ++项目。在这里面,对于 MergeApkRecipelists 任务元素看起来像这样:

 <  - 语言:郎XML  - >
< MergeApkRecipelists RecipeFiles =@(_ NativeAndroidRecipeFiles)>
        ...
< / MergeApkRecipelists>
 

NativeAndroidRecipeFiles 变量似乎并没有在.targets文件中定义,所以presumably它正在构建过程初始化。但是,由于.targets文件似乎旨在支持C ++项目裁判,我试图加入一个Android的C ++共享库项目,我的解决方案:

然后,我引用的C ++项目从我Xamarin的Andr​​oid项目,瞧!建立并运行之后是成功的。

但因为它是pretty的繁重不得不引入一个虚拟的lib,我也找到了在那里Xamarin的Microsoft.Cpp.Android.targets文件被拉到这发生在C:\ Program Files文件(86) \的MSBuild \ Xamarin \机器人\ Xamarin.Android.Common.After.targets文件,里面有一个导入元素:

 <  - 语言:郎XML  - >
<导入项目=$(MSBuildThisFileDirectory)\ Xamarin.Android.Common \ ImportAfter \ *
        条件=存在('$(MSBuildThisFileDirectory)\ Xamarin.Android.Common \ ImportAfter')/>
 

这带来了下%PROGRAMFILES(x86)的\的MSBuild \ Xamarin \机器人\ Xamarin.Android.Common \ ImportAfter一切。由于在该目录中唯一的产品,我们要排除的.targets文件,这可以被注释掉,而不会影响任何东西。但是,注意的是,由于这.targets文件似乎是支持引用来自Xamarin的Andr​​oid项目C ++项目,评论了这一点,presumably意味着将不再正常工作的一部分。

使用了导入语句注释掉,则Xamarin的Andr​​oid项目应建立和运行,没有任何C ++引用。

I'm using recently released Visual Studio 2015 Preview along with Xamarian Studio 5.6.3(or 5.6.2) extension for Visual studio.

After Hours of downloading and installing all required software (all done successfully), I started developing Android Application in VS2015P, but every time I create blank Android application, I get this error, with no error code:

The "MergeApkRecipelists" task was not given a value for the required parameter "RecipeFiles".

解决方案

Figured this out by looking at Xamarin's .targets files.

Short Version

You can either:

Create an Android C++ library project and reference that from your Xamarin Android project

or

Comment out the Import element defined in %PROGRAMFILES(x86)%\MSBuild\Xamarin\Android\Xamarin.Android.Common.After.targets. Note this will likely disable support for adding C++ project references to Xamarin Android projects.

Once you do one of those, your Xamarin Android project should build and run.

Long Version

First, note the error in the VS output window:

C:\Program Files (x86)\MSBuild\Xamarin\Android\Xamarin.Android.Common\ImportAfter\Microsoft.Cpp.Android.targets(54,9): error MSB4044: The "MergeApkRecipelists" task was not given a value for the required parameter "RecipeFiles".

The Microsoft.Cpp.Android.targets file mentioned in the error looks to be all about supporting project references to C++ projects. In it, the element for the MergeApkRecipelists task looks like so:

<!-- language: lang-xml -->
<MergeApkRecipelists RecipeFiles="@(_NativeAndroidRecipeFiles)">
        ...
</MergeApkRecipelists>

The NativeAndroidRecipeFiles variable doesn't seem to be defined in the .targets files, so presumably it's being initialized by the build process. But since the .targets file seems to be aimed at supporting C++ project refs, I tried adding an Android C++ shared library project to my solution:

Then I referenced the C++ project from my Xamarin Android project, and voila! Building and running afterwards was successful.

But since it's pretty onerous to have to bring in a dummy lib, I also tracked down where Xamarin's Microsoft.Cpp.Android.targets file gets pulled in. This happens in the C:\Program Files (x86)\MSBuild\Xamarin\Android\Xamarin.Android.Common.After.targets file, which has one Import element:

<!-- language: lang-xml -->
<Import Project="$(MSBuildThisFileDirectory)\Xamarin.Android.Common\ImportAfter\*"
        Condition="Exists('$(MSBuildThisFileDirectory)\Xamarin.Android.Common\ImportAfter')"/>

That brings in everything under %PROGRAMFILES(x86)\MSBuild\Xamarin\Android\Xamarin.Android.Common\ImportAfter. Since the only item in that directory is the .targets file we want to exclude, this can be commented out without affecting anything else. But note that, since this .targets file appears to be part of support for referencing C++ projects from Xamarin Android projects, commenting this out presumably means that will no longer work properly.

With that Import statement commented out, the Xamarin Android project should build and run without any C++ references.

 
精彩推荐
图片推荐