寸阳分阴须爱惜,休负春色与时光。这篇文章主要讲述在Xamarin Android项目中的android Assets中添加文件夹会引发Build Error相关的知识,希望能为你提供帮助。
无法在Xamarin android项目中的Assets中添加目录和子目录。
IDE:适用于Mac的Visual Studio社区版本:7.3.2(版本12)
操作系统:MacOS High Sierra版本:10.13.2
错误:/ Library/Frameworks/Mono.framework/External/xbuild/Xamarin/Android/Xamarin.Android.Common.targets(2,2):错误MSB3025:源文件“Assets / Dir /”实际上是一个目录。 “复制”任务不支持复制目录。 (MSB3025)(assetsCheck)
/Library/Frameworks/Mono.framework/External/xbuild/Xamarin/Android/Xamarin.Android.Common.targets(2,2):错误MSB3025:源文件“Assets / Dir / SubDir /”实际上是一个目录。 “复制”任务不支持复制目录。 (MSB3025)(assetsCheck)
注意能够在Windows 10系统中使用Visual Studio社区成功构建。
.csproj文件
<
?xml version="1.0" encoding="utf-8"?>
<
Project DefaultTargets="Build" ToolsVersion="4.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<
Import Project="..packagesXamarin.Build.Download.0.4.3uildXamarin.Build.Download.props" Condition="Exists('..packagesXamarin.Build.Download.0.4.3uildXamarin.Build.Download.props')" />
<
PropertyGroup>
<
Configuration Condition=" '$(Configuration)' == '' ">
Debug<
/Configuration>
<
Platform Condition=" '$(Platform)' == '' ">
AnyCPU<
/Platform>
<
ProjectGuid>
{A6BF443D-8B89-4044-B951-E346FA8E68D3}<
/ProjectGuid>
<
ProjectTypeGuids>
{EFBA0AD7-5A72-4C68-AF49-83D382785DCF};
{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}<
/ProjectTypeGuids>
<
OutputType>
Library<
/OutputType>
<
RootNamespace>
ScormReader.Droid<
/RootNamespace>
<
AssemblyName>
ScormReader.Droid<
/AssemblyName>
<
TargetFrameworkVersion>
v8.0<
/TargetFrameworkVersion>
<
AndroidApplication>
True<
/AndroidApplication>
<
AndroidResgenFile>
ResourcesResource.designer.cs<
/AndroidResgenFile>
<
AndroidResgenClass>
Resource<
/AndroidResgenClass>
<
AndroidManifest>
PropertiesAndroidManifest.xml<
/AndroidManifest>
<
MonoAndroidResourcePrefix>
Resources<
/MonoAndroidResourcePrefix>
<
MonoAndroidAssetsPrefix>
Assets<
/MonoAndroidAssetsPrefix>
<
AndroidUseLatestPlatformSdk>
true<
/AndroidUseLatestPlatformSdk>
<
/PropertyGroup>
<
PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
<
DebugSymbols>
true<
/DebugSymbols>
<
DebugType>
full<
/DebugType>
<
Optimize>
false<
/Optimize>
<
OutputPath>
binDebug<
/OutputPath>
<
DefineConstants>
DEBUG;
<
/DefineConstants>
<
ErrorReport>
prompt<
/ErrorReport>
<
WarningLevel>
4<
/WarningLevel>
<
AndroidLinkMode>
None<
/AndroidLinkMode>
<
AndroidSupportedAbis>
arm64-v8a;
armeabi;
armeabi-v7a;
x86<
/AndroidSupportedAbis>
<
/PropertyGroup>
<
PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' ">
<
DebugSymbols>
true<
/DebugSymbols>
<
DebugType>
pdbonly<
/DebugType>
<
Optimize>
true<
/Optimize>
<
OutputPath>
binRelease<
/OutputPath>
<
ErrorReport>
prompt<
/ErrorReport>
<
WarningLevel>
4<
/WarningLevel>
<
AndroidManagedSymbols>
true<
/AndroidManagedSymbols>
<
AndroidUseSharedRuntime>
false<
/AndroidUseSharedRuntime>
<
/PropertyGroup>
<
ItemGroup>
<
Reference Include="System" />
<
Reference Include="System.Xml" />
<
Reference Include="System.Core" />
<
Reference Include="Mono.Android" />
<
Reference Include="Xamarin.Android.Support.Annotations">
<
HintPath>
..packagesXamarin.Android.Support.Annotations.25.3.1libMonoAndroid70Xamarin.Android.Support.Annotations.dll<
/HintPath>
<
/Reference>
<
Reference Include="Xamarin.Android.Support.Compat">
<
HintPath>
..packagesXamarin.Android.Support.Compat.25.3.1libMonoAndroid70Xamarin.Android.Support.Compat.dll<
/HintPath>
<
/Reference>
<
Reference Include="Xamarin.Android.Support.Core.UI">
<
HintPath>
..packagesXamarin.Android.Support.Core.UI.25.3.1libMonoAndroid70Xamarin.Android.Support.Core.UI.dll<
/HintPath>
<
/Reference>
<
Reference Include="Xamarin.Android.Support.Core.Utils">
<
HintPath>
..packagesXamarin.Android.Support.Core.Utils.25.3.1libMonoAndroid70Xamarin.Android.Support.Core.Utils.dll<
/HintPath>
<
/Reference>
<
Reference Include="Xamarin.Android.Support.Media.Compat">
<
HintPath>
..packagesXamarin.Android.Support.Media.Compat.25.3.1libMonoAndroid70Xamarin.Android.Support.Media.Compat.dll<
/HintPath>
<
/Reference>
<
Reference Include="Xamarin.Android.Support.Fragment">
<
HintPath>
..packagesXamarin.Android.Support.Fragment.25.3.1libMonoAndroid70Xamarin.Android.Support.Fragment.dll<
/HintPath>
<
/Reference>
<
Reference Include="Xamarin.Android.Support.Vector.Drawable">
<
HintPath>
..packagesXamarin.Android.Support.Vector.Drawable.25.3.1libMonoAndroid70Xamarin.Android.Support.Vector.Drawable.dll<
/HintPath>
<
/Reference>
<
Reference Include="Xamarin.Android.Support.Animated.Vector.Drawable">
<
HintPath>
..packagesXamarin.Android.Support.Animated.Vector.Drawable.25.3.1libMonoAndroid70Xamarin.Android.Support.Animated.Vector.Drawable.dll<
/HintPath>
<
/Reference>
<
Reference Include="Xamarin.Android.Support.v7.AppCompat">
<
HintPath>
..packagesXamarin.Android.Support.v7.AppCompat.25.3.1libMonoAndroid70Xamarin.Android.Support.v7.AppCompat.dll<
/HintPath>
<
/Reference>
<
/ItemGroup>
<
ItemGroup>
<
Compile Include="MainActivity.cs" />
<
Compile Include="ResourcesResource.designer.cs" />
<
Compile Include="PropertiesAssemblyInfo.cs" />
<
/ItemGroup>
<
ItemGroup>
<
None Include="ResourcesAboutResources.txt" />
<
None Include="PropertiesAndroidManifest.xml" />
<
None Include="AssetsAboutAssets.txt" />
<
None Include="packages.config" />
<
/ItemGroup>
<
ItemGroup>
<
AndroidResource Include="ResourceslayoutMain.axml" />
<
AndroidResource Include="ResourcesvaluesStrings.xml" />
<
AndroidResource Include="Resourcesmipmap-hdpiIcon.png" />
<
AndroidResource Include="Resourcesmipmap-mdpiIcon.png" />
<
AndroidResource Include="Resourcesmipmap-xhdpiIcon.png" />
<
AndroidResource Include="Resourcesmipmap-xxhdpiIcon.png" />
<
AndroidResource Include="Resourcesmipmap-xxxhdpiIcon.png" />
<
/ItemGroup>
<
ItemGroup>
<
Folder Include="Resourcesdrawable" />
<
/ItemGroup>
<
ItemGroup>
<
/ItemGroup>
<
ItemGroup>
<
/ItemGroup>
<
ItemGroup>
<
AndroidAsset Include="AssetsParent" />
<
AndroidAsset Include="AssetsParentChild" />
<
/ItemGroup>
<
Import Project="$(MSBuildExtensionsPath)XamarinAndroidXamarin.Android.CSharp.targets" />
<
Import Project="..packagesXamarin.Build.Download.0.4.3uildXamarin.Build.Download.targets" Condition="Exists('..packagesXamarin.Build.Download.0.4.3uildXamarin.Build.Download.targets')" />
<
Import Project="..packagesXamarin.Android.Support.Annotations.25.3.1uildMonoAndroid70Xamarin.Android.Support.Annotations.targets" Condition="Exists('..packagesXamarin.Android.Support.Annotations.25.3.1uildMonoAndroid70Xamarin.Android.Support.Annotations.targets')" />
<
Import Project="..packagesXamarin.Android.Support.Compat.25.3.1uildMonoAndroid70Xamarin.Android.Support.Compat.targets" Condition="Exists('..packagesXamarin.Android.Support.Compat.25.3.1uildMonoAndroid70Xamarin.Android.Support.Compat.targets')" />
<
Import Project="..packagesXamarin.Android.Support.Core.UI.25.3.1uildMonoAndroid70Xamarin.Android.Support.Core.UI.targets" Condition="Exists('..packagesXamarin.Android.Support.Core.UI.25.3.1uildMonoAndroid70Xamarin.Android.Support.Core.UI.targets')" />
<
Import Project="..packagesXamarin.Android.Support.Core.Utils.25.3.1uildMonoAndroid70Xamarin.Android.Support.Core.Utils.targets" Condition="Exists('..packagesXamarin.Android.Support.Core.Utils.25.3.1uildMonoAndroid70Xamarin.Android.Support.Core.Utils.targets')" />
<
Import Project="..packagesXamarin.Android.Support.Media.Compat.25.3.1uildMonoAndroid70Xamarin.Android.Support.Media.Compat.targets" Condition="Exists('..packagesXamarin.Android.Support.Media.Compat.25.3.1uildMonoAndroid70Xamarin.Android.Support.Media.Compat.targets')" />
<
Import Project="..packagesXamarin.Android.Support.Fragment.25.3.1uildMonoAndroid70Xamarin.Android.Support.Fragment.targets" Condition="Exists('..packagesXamarin.Android.Support.Fragment.25.3.1uildMonoAndroid70Xamarin.Android.Support.Fragment.targets')" />
<
Import Project="..packagesXamarin.Android.Support.Vector.Drawable.25.3.1uildMonoAndroid70Xamarin.Android.Support.Vector.Drawable.targets" Condition="Exists('..packagesXamarin.Android.Support.Vector.Drawable.25.3.1uildMonoAndroid70Xamarin.Android.Support.Vector.Drawable.targets')" />
<
Import Project="..packagesXamarin.Android.Support.Animated.Vector.Drawable.25.3.1uildMonoAndroid70Xamarin.Android.Support.Animated.Vector.Drawable.targets" Condition="Exists('..packagesXamarin.Android.Support.Animated.Vector.Drawable.25.3.1uildMonoAndroid70Xamarin.Android.Support.Animated.Vector.Drawable.targets')" />
<
Import Project="..packagesXamarin.Android.Support.v7.AppCompat.25.3.1uildMonoAndroid70Xamarin.Android.Support.v7.AppCompat.targets" Condition="Exists('..packagesXamarin.Android.Support.v7.AppCompat.25.3.1uildMonoAndroid70Xamarin.Android.Support.v7.AppCompat.targets')" />
<
/Project>
答案
“复制”任务不支持复制目录。我在我的MacOS上重现了你的问题,并找到了修复程序。添加子目录时,
csproj
文件添加了一个导致此错误的项目。编辑csproj
文件并删除引用子目录的行将解决此问题。Solution :我的
.csproj
文件:<
ItemGroup>
<
AndroidAsset Include="AssetsNew Folderhi.txt">
<
Generator>
RazorTemplatePreprocessor<
/Generator>
<
LastGenOutput>
hi.cs<
/LastGenOutput>
<
/AndroidAsset>
<
AndroidAsset Include="AssetsNew Folder1" />
<
/ItemGroup>
删除引用子目录的第一个AndroidAsset:
【在Xamarin Android项目中的android Assets中添加文件夹会引发Build Error】
文章图片
推荐阅读
- 为什么在NUnit Android Test Runner中Asserts等于0(零)()
- 无法在Android上使用C ++ OpenCV打开相机
- Xamarin Android - 如何在textview动画期间阻止文本移动
- 如何为Android转换器中的MvxColor指定Hex或RGB颜色
- 没有声明Xamarin.Android Button Border
- Xamarin.Android WebView App性能问题
- 如何从xamarin表单应用程序中的PCL项目访问android原生布局文件()
- 在Xamarin.Android中将Keycode转换为char
- 获取ObtainStyledAttributes以在Android的xamarin中正常工作