首页 > 解决方案 > 在“来源”参数中多次指定了 X 项

问题描述

我有一个 Xamarin.Forms 项目,我将图像拖放到我的 Android 资源文件夹中,然后将其复制并粘贴到我的 UWP 项目中,但图像不显示,因此我将其构建操作更改为内容,但它显示错误:

Error The item "obj\Debug\MainPage.xaml.g.cs" was specified more than once in the "Sources" parameter. Duplicate items are not supported by the "Sources" parameter. XamaTask.Android
我不确定它是否与图像有关,但是在我复制、重命名和更改该构建操作属性后,错误开始显示,我还删除了图像并再次重命名并检查了我的 Android.csproject 但我没有发现任何重复物品。
编辑
我找到了有错误的文件,但同样,我没有找到任何重复的,这里是代码:

//------------------------------------------------------------------------------
// <auto-generated>
//     This code was generated by a tool.
//     Runtime Version:4.0.30319.42000
//
//     Changes to this file may cause incorrect behavior and will be lost if
//     the code is regenerated.
// </auto-generated>
//------------------------------------------------------------------------------

[assembly: global::Xamarin.Forms.Xaml.XamlResourceIdAttribute("XamaTask.Droid.MainPage.xaml", "MainPage.xaml", typeof(global::XamaTask.MainPage))]

namespace XamaTask {


    [global::Xamarin.Forms.Xaml.XamlFilePathAttribute("C:\\Users\\M\\source\\repos\\XamaTask\\XamaTask\\XamaTask\\MainPage.xaml")]
    public partial class MainPage : global::Xamarin.Forms.ContentPage {

        [global::System.CodeDom.Compiler.GeneratedCodeAttribute("Xamarin.Forms.Build.Tasks.XamlG", "2.0.0.0")]
        private void InitializeComponent() {
            global::Xamarin.Forms.Xaml.Extensions.LoadFromXaml(this, typeof(MainPage));
        }
    }
}

标签: c#xamlxamarinxamarin.forms

解决方案


我在一次糟糕的合并后遇到了这个问题。我编辑了 .csproj 并删除了两次包含相同 .cs 文件的重复行。


推荐阅读