新创建的跨平台 Xamarin.Forms 项目在更新 NuGet 包后无法构建
Newly created Cross-Platform Xamarin.Forms project fails to build after updating NuGet Packages
我正在尝试使用 Xamarin.forms 在 Visual Studio Community 2017(版本 15.9.5)中创建跨平台移动应用程序。
创建项目后,我更新了 NuGet 包并收到 3 个错误和 1 个警告(注意:我根本没有编写任何代码)。
你可以在下面找到我所做的详细过程和详细的错误消息。
我单击“文件”>“新建”>“项目”>“Visual C#”>“跨平台”>“移动应用”(Xamarin.Forms)。
我为我的项目命名,系统提示我选择一个模板,我 select "Blank App"。
对于平台,我选择全部 3 个(iOS、Android、UWP),作为代码共享策略,我选择 "Shared Project"。
创建项目后,我打开 NuGet 包管理器并更新我的所有包,在这里您可以看到它们的最新版本。
软件包更新后,我收到 7 条警告和 1 条错误。我清理并重建了解决方案,但我不断收到这些错误和警告,尽管它们有时会发生变化而我没有做任何更改。
我可能会看到 7 个警告但没有错误,关闭项目,再次打开它,重新生成并得到 3 个错误和 1 个警告。
这是目前的错误列表:
这里是完整的输出:
1>------ Rebuild All started: Project: Bencivenga_Gioele_Bengalino.Android, Configuration: Debug Any CPU ------
2>------ Skipped Rebuild All: Project: Bencivenga_Gioele_Bengalino.iOS, Configuration: Debug iPhone ------
2>Project not selected to build for this solution configuration
3>------ Rebuild All started: Project: Bencivenga_Gioele_Bengalino.UWP, Configuration: Debug x86 ------
1>C:\Program Files (x86)\Microsoft Visual Studio17\Community\MSBuild\Xamarin\Android\Xamarin.Android.Common.targets(3064,2): error : The specified path, file name, or both are too long. The fully qualified file name must be less than 260 characters, and the directory name must be less than 248 characters.
1>C:\Program Files (x86)\Microsoft Visual Studio17\Community\MSBuild\Xamarin\Android\Xamarin.Android.Common.targets(1327,2): error XA4303: Error extracting resources from "C:\Users\gioel.nuget\packages\xamarin.android.support.compat.0.0.1\lib\monoandroid81\Xamarin.Android.Support.Compat.dll": System.IO.PathTooLongException: The specified path, file name, or both are too long. The fully qualified file name must be less than 260 characters, and the directory name must be less than 248 characters.
1>C:\Program Files (x86)\Microsoft Visual Studio17\Community\MSBuild\Xamarin\Android\Xamarin.Android.Common.targets(1327,2): error XA4303: at System.IO.LongPathHelper.Normalize(String path, UInt32 maxPathLength, Boolean checkInvalidCharacters, Boolean expandShortPaths)
1>C:\Program Files (x86)\Microsoft Visual Studio17\Community\MSBuild\Xamarin\Android\Xamarin.Android.Common.targets(1327,2): error XA4303: at System.IO.Path.NewNormalizePath(String path, Int32 maxPathLength, Boolean expandShortPaths)
1>C:\Program Files (x86)\Microsoft Visual Studio17\Community\MSBuild\Xamarin\Android\Xamarin.Android.Common.targets(1327,2): error XA4303: at System.IO.Path.NormalizePath(String path, Boolean fullCheck, Int32 maxPathLength, Boolean expandShortPaths)
1>C:\Program Files (x86)\Microsoft Visual Studio17\Community\MSBuild\Xamarin\Android\Xamarin.Android.Common.targets(1327,2): error XA4303: at System.IO.Path.GetFullPathInternal(String path)
1>C:\Program Files (x86)\Microsoft Visual Studio17\Community\MSBuild\Xamarin\Android\Xamarin.Android.Common.targets(1327,2): error XA4303: at Xamarin.Android.Tools.Files.ExtractAll(ZipArchive zip, String destination, Action2 progressCallback, Func
2 modifyCallback, Func2 deleteCallback, Boolean forceUpdate)
1>C:\Program Files (x86)\Microsoft Visual Studio17\Community\MSBuild\Xamarin\Android\Xamarin.Android.Common.targets(1327,2): error XA4303: at Xamarin.Android.Tasks.ResolveLibraryProjectImports.Extract(DirectoryAssemblyResolver res, ICollection
1 jars, ICollection1 resolvedResourceDirectories, ICollection
1 resolvedAssetDirectories, ICollection`1 resolvedEnvironments)
3> Bencivenga_Gioele_Bengalino.UWP -> C:\Users\gioel\Documents\Repositories\GitHub\BengalinoUWP\Bencivenga_Gioele_BengalinoApp\Bencivenga_Gioele_Bengalino\Bencivenga_Gioele_Bengalino\Bencivenga_Gioele_Bengalino.UWP\bin\x86\Debug\Bencivenga_Gioele_Bengalino.UWP.exe
3>C:\Users\gioel.nuget\packages\microsoft.net.uwpcoreruntimesdk.1.2\tools\CoreRuntime\Microsoft.Net.CoreRuntime.targets(195,9): error : Framework resource extraction failed. The specified path, file name, or both are too long. The fully qualified file name must be less than 260 characters, and the directory name must be less than 248 characters.
========== Rebuild All: 0 succeeded, 2 failed, 1 skipped ==========
我在网上搜索了一个解决方案,发现了一些旧线程,他们建议使用 LongPathTool 来解决最大 260 个字符的问题,但他们的说明是 "just install it and it will work" 好吧,这样做并没有成功任何对我有用的东西。
感谢您阅读问题,如果您能就此问题给我任何想法或建议,则更加感谢。欢迎询问更多详情。
将您的项目移至 C://
的根目录,通常这可以解决该特定错误。
尝试在 C:\Users\
中创建一个名为 XamarinProjects 的文件夹,并将您的解决方案放在那里。
经过一番挖掘,我发现了这个:
<PropertyGroup>
<UseShortFileNames>True</UseShortFileNames>
</PropertyGroup>
如果设置此标志不能修复 PathTooLongException 错误,另一种方法是通过在项目 .csproj 文件中设置 IntermediateOutputPath 为解决方案中的项目指定一个公共中间输出根。尝试使用相对较短的路径。例如:
<PropertyGroup>
<IntermediateOutputPath>C:\Projects\MyApp</IntermediateOutputPath>
</PropertyGroup>
我正在尝试使用 Xamarin.forms 在 Visual Studio Community 2017(版本 15.9.5)中创建跨平台移动应用程序。
创建项目后,我更新了 NuGet 包并收到 3 个错误和 1 个警告(注意:我根本没有编写任何代码)。
你可以在下面找到我所做的详细过程和详细的错误消息。
我单击“文件”>“新建”>“项目”>“Visual C#”>“跨平台”>“移动应用”(Xamarin.Forms)。
我为我的项目命名,系统提示我选择一个模板,我 select "Blank App"。
对于平台,我选择全部 3 个(iOS、Android、UWP),作为代码共享策略,我选择 "Shared Project"。
创建项目后,我打开 NuGet 包管理器并更新我的所有包,在这里您可以看到它们的最新版本。
我可能会看到 7 个警告但没有错误,关闭项目,再次打开它,重新生成并得到 3 个错误和 1 个警告。
这是目前的错误列表:
这里是完整的输出:
1>------ Rebuild All started: Project: Bencivenga_Gioele_Bengalino.Android, Configuration: Debug Any CPU ------ 2>------ Skipped Rebuild All: Project: Bencivenga_Gioele_Bengalino.iOS, Configuration: Debug iPhone ------ 2>Project not selected to build for this solution configuration 3>------ Rebuild All started: Project: Bencivenga_Gioele_Bengalino.UWP, Configuration: Debug x86 ------ 1>C:\Program Files (x86)\Microsoft Visual Studio17\Community\MSBuild\Xamarin\Android\Xamarin.Android.Common.targets(3064,2): error : The specified path, file name, or both are too long. The fully qualified file name must be less than 260 characters, and the directory name must be less than 248 characters. 1>C:\Program Files (x86)\Microsoft Visual Studio17\Community\MSBuild\Xamarin\Android\Xamarin.Android.Common.targets(1327,2): error XA4303: Error extracting resources from "C:\Users\gioel.nuget\packages\xamarin.android.support.compat.0.0.1\lib\monoandroid81\Xamarin.Android.Support.Compat.dll": System.IO.PathTooLongException: The specified path, file name, or both are too long. The fully qualified file name must be less than 260 characters, and the directory name must be less than 248 characters. 1>C:\Program Files (x86)\Microsoft Visual Studio17\Community\MSBuild\Xamarin\Android\Xamarin.Android.Common.targets(1327,2): error XA4303: at System.IO.LongPathHelper.Normalize(String path, UInt32 maxPathLength, Boolean checkInvalidCharacters, Boolean expandShortPaths) 1>C:\Program Files (x86)\Microsoft Visual Studio17\Community\MSBuild\Xamarin\Android\Xamarin.Android.Common.targets(1327,2): error XA4303: at System.IO.Path.NewNormalizePath(String path, Int32 maxPathLength, Boolean expandShortPaths) 1>C:\Program Files (x86)\Microsoft Visual Studio17\Community\MSBuild\Xamarin\Android\Xamarin.Android.Common.targets(1327,2): error XA4303: at System.IO.Path.NormalizePath(String path, Boolean fullCheck, Int32 maxPathLength, Boolean expandShortPaths) 1>C:\Program Files (x86)\Microsoft Visual Studio17\Community\MSBuild\Xamarin\Android\Xamarin.Android.Common.targets(1327,2): error XA4303: at System.IO.Path.GetFullPathInternal(String path) 1>C:\Program Files (x86)\Microsoft Visual Studio17\Community\MSBuild\Xamarin\Android\Xamarin.Android.Common.targets(1327,2): error XA4303: at Xamarin.Android.Tools.Files.ExtractAll(ZipArchive zip, String destination, Action
2 progressCallback, Func
2 modifyCallback, Func2 deleteCallback, Boolean forceUpdate) 1>C:\Program Files (x86)\Microsoft Visual Studio17\Community\MSBuild\Xamarin\Android\Xamarin.Android.Common.targets(1327,2): error XA4303: at Xamarin.Android.Tasks.ResolveLibraryProjectImports.Extract(DirectoryAssemblyResolver res, ICollection
1 jars, ICollection1 resolvedResourceDirectories, ICollection
1 resolvedAssetDirectories, ICollection`1 resolvedEnvironments) 3> Bencivenga_Gioele_Bengalino.UWP -> C:\Users\gioel\Documents\Repositories\GitHub\BengalinoUWP\Bencivenga_Gioele_BengalinoApp\Bencivenga_Gioele_Bengalino\Bencivenga_Gioele_Bengalino\Bencivenga_Gioele_Bengalino.UWP\bin\x86\Debug\Bencivenga_Gioele_Bengalino.UWP.exe 3>C:\Users\gioel.nuget\packages\microsoft.net.uwpcoreruntimesdk.1.2\tools\CoreRuntime\Microsoft.Net.CoreRuntime.targets(195,9): error : Framework resource extraction failed. The specified path, file name, or both are too long. The fully qualified file name must be less than 260 characters, and the directory name must be less than 248 characters. ========== Rebuild All: 0 succeeded, 2 failed, 1 skipped ==========
我在网上搜索了一个解决方案,发现了一些旧线程,他们建议使用 LongPathTool 来解决最大 260 个字符的问题,但他们的说明是 "just install it and it will work" 好吧,这样做并没有成功任何对我有用的东西。
感谢您阅读问题,如果您能就此问题给我任何想法或建议,则更加感谢。欢迎询问更多详情。
将您的项目移至 C://
的根目录,通常这可以解决该特定错误。
尝试在 C:\Users\
中创建一个名为 XamarinProjects 的文件夹,并将您的解决方案放在那里。
经过一番挖掘,我发现了这个:
<PropertyGroup>
<UseShortFileNames>True</UseShortFileNames>
</PropertyGroup>
如果设置此标志不能修复 PathTooLongException 错误,另一种方法是通过在项目 .csproj 文件中设置 IntermediateOutputPath 为解决方案中的项目指定一个公共中间输出根。尝试使用相对较短的路径。例如:
<PropertyGroup>
<IntermediateOutputPath>C:\Projects\MyApp</IntermediateOutputPath>
</PropertyGroup>