更新了NuGet软件包后,新创建的跨平台Xamarin.Forms项目无法构建

时间:2019-01-22 19:00:45

标签: visual-studio xamarin xamarin.forms cross-platform

我正在尝试在Visual Studio Community 2017(版本15.9.5)中使用Xamarin.forms创建跨平台移动应用程序。

创建项目后,我更新了NuGet软件包,并收到3个错误和1个警告(注意:我根本没有编写任何代码)。

下面您可以找到我的详细操作过程和详细的错误消息。

我单击文件>新建>项目> Visual C#>跨平台>移动应用程序(Xamarin.Forms)。

我为我的项目命名,并提示我选择一个模板,然后选择“空白应用程序”。

对于平台,我选择全部3种(iOS,Android,UWP),并且作为代码共享策略,我选择“ Shared Project”。

创建项目后,我打开NuGet软件包管理器并更新我的所有软件包,在这里您可以看到它们的最新版本。PackageList 更新软件包后,我会收到7条警告和1条错误。我清理并重建了解决方案,但我不断收到这些错误和警告,尽管它们有时会更改,而无需我进行任何更改。

我可能会看到7条警告,没有错误,请关闭项目,然后再次打开它,进行重建,并得到3条错误和1条警告。

这是当前错误列表:Errors

这是完整的输出:

  

1> ------重建全部开始:项目:Bencivenga_Gioele_Bengalino.Android,配置:调试任何CPU ------   2> ------跳过全部重建:项目:Bencivenga_Gioele_Bengalino.iOS,配置:调试iPhone ------   2>未选择要为此解决方案配置构建的项目   3> ------重建全部开始:项目:Bencivenga_Gioele_Bengalino.UWP,配置:调试x86 ------   1> C:\ Program Files(x86)\ Microsoft Visual Studio \ 2017 \ Community \ MSBuild \ Xamarin \ Android \ Xamarin.Android.Common.targets(3064,2):error:指定的路径,文件名或两者都是太长。完全限定的文件名必须少于260个字符,目录名称必须少于248个字符。   1> C:\ Program Files(x86)\ Microsoft Visual Studio \ 2017 \ Community \ MSBuild \ Xamarin \ Android \ Xamarin.Android.Common.targets(1327,2):错误XA4303:从“ C:\ Users \ gioel.nuget \ packages \ xamarin.android.support.compat \ 28.0.0.1 \ lib \ monoandroid81 \ Xamarin.Android.Support.Compat.dll“:System.IO.PathTooLongException:指定的路径,文件名或两者都是太长。完全限定的文件名必须少于260个字符,目录名称必须少于248个字符。   1> C:\ Program Files(x86)\ Microsoft Visual Studio \ 2017 \ Community \ MSBuild \ Xamarin \ Android \ Xamarin.Android.Common.targets(1327,2):错误XA4303:位于System.IO.LongPathHelper.Normalize(字符串路径,UInt32 maxPathLength,布尔值checkInvalidCharacters,布尔值expandShortPaths)   1> C:\ Program Files(x86)\ Microsoft Visual Studio \ 2017 \ Community \ MSBuild \ Xamarin \ Android \ Xamarin.Android.Common.targets(1327,2):错误XA4303:位于System.IO.Path.NewNormalizePath(字符串路径,Int32 maxPathLength,布尔布尔expandShortPaths)   1> C:\ Program Files(x86)\ Microsoft Visual Studio \ 2017 \ Community \ MSBuild \ Xamarin \ Android \ Xamarin.Android.Common.targets(1327,2):错误XA4303:位于System.IO.Path.NormalizePath(字符串路径,布尔型fullCheck,Int32 maxPathLength,布尔型expandShortPaths)   1> C:\ Program Files(x86)\ Microsoft Visual Studio \ 2017 \ Community \ MSBuild \ Xamarin \ Android \ Xamarin.Android.Common.targets(1327,2):错误XA4303:位于System.IO.Path.GetFullPathInternal(字符串路径)   1> C:\ Program Files(x86)\ Microsoft Visual Studio \ 2017 \ Community \ MSBuild \ Xamarin \ Android \ Xamarin.Android.Common.targets(1327,2):错误XA4303:位于Xamarin.Android.Tools.Files。 ExtractAll(ZipArchive邮编,字符串目标,Action 2 progressCallback, Func 2 ModifyCallback,Func 2 deleteCallback, Boolean forceUpdate) 1>C:\Program Files (x86)\Microsoft Visual Studio\2017\Community\MSBuild\Xamarin\Android\Xamarin.Android.Common.targets(1327,2): error XA4303: at Xamarin.Android.Tasks.ResolveLibraryProjectImports.Extract(DirectoryAssemblyResolver res, ICollection 1个jar,ICollection 1 resolvedResourceDirectories, ICollection 1 resolveAssetDirectories,ICollection`1 resolveEnvironments)   3> Bencivenga_Gioele_Bengalino.UWP-> C:\ Users \ gioel \ Documents \ Repositories \ GitHub \ BengalinoUWP \ Bencivenga_Gioele_BengalinoApp \ Bencivenga_Gioele_Bengalino \ Bencivenga_Gioele_Bengalino \ Bencivenga_x。   3> C:\ Users \ gioel.nuget \ packages \ microsoft.net.uwpcoreruntimesdk \ 2.1.2 \ tools \ CoreRuntime \ Microsoft.Net.CoreRuntime.targets(195,9):错误:框架资源提取失败。指定的路径,文件名或两者都太长。完全限定的文件名必须少于260个字符,目录名称必须少于248个字符。   ===========全部重建:0成功,2失败,1跳过==========

我在网上搜索了一个解决方案,并发现了一些建议使用LongPathTool的旧线程,以消除最大260个字符的问题,但他们的指示是“只要安装它就可以了”,那么,这样做不是。没什么对我有用。

感谢您阅读问题,如果您对这个问题有任何想法或建议,我们将非常感谢。随时询问更多细节。

1 个答案:

答案 0 :(得分:2)

将您的项目移至C://的根目录,通常可以解决该特定错误。

尝试在C:\Users\中创建一个名为XamarinProjects的文件夹,然后将解决方案放在此处。

经过一番挖掘,我发现了这一点:

<PropertyGroup>
    <UseShortFileNames>True</UseShortFileNames>
</PropertyGroup>

如果设置此标志不能解决PathTooLongException错误,另一种方法是通过在项目.csproj文件中设置IntermediateOutputPath为解决方案中的项目指定公共的中间输出根。尝试使用相对较短的路径。例如:

<PropertyGroup>
    <IntermediateOutputPath>C:\Projects\MyApp</IntermediateOutputPath>
</PropertyGroup>

来自Official Documentation

相关问题