在我从 PCL 转换为 .NET 共享后,我试图了解 .csproj 文件的内容。这是一个例子和一些问题:
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<TargetFramework>netstandard2.0</TargetFramework>
</PropertyGroup>
<ItemGroup>
<PackageReference Include="Xamarin.Forms" Version="3.1.0.583944" />
<PackageReference Include="sqlite-net-pcl" Version="1.4.118" />
<PackageReference Include="Syncfusion.Xamarin.SfChart" Version="16.2.0.42" />
</ItemGroup>
<ItemGroup>
<Folder Include="Views\" />
<Folder Include="Views\Settings\Pages\" />
<Folder Include="Views\Home\PopUp\" />
<Folder Include="Views\Help\Cards\" />
</ItemGroup>
有人可以向我解释为什么即使我的项目有更多文件夹,但上面只出现某些文件夹
<ItemGroup>
<EmbeddedResource Remove="Views\Cards\Category\CategoriesPage.xaml" />
<EmbeddedResource Remove="Views\Cards\Templates\LinkTextCell.xaml" />
<EmbeddedResource Remove="Views\Cards\Templates\SwitchViewCell.xaml" />
<EmbeddedResource Remove="Views\Home\Dictionary.xaml" />
</ItemGroup>
有人可以解释所有这些 Remove 行的作用/含义吗?
<ItemGroup>
<None Include="Views\Cards\Cards.xaml" />
<None Include="Views\Cards\Category\CategoriesPage.xaml" />
<None Include="Views\Cards\Category\CategoryViewCell.xaml" />
<None Include="Views\Cards\Templates\LinkTextCell.xaml" />
<None Include="Views\Cards\Templates\SwitchViewCell.xaml" />
<None Include="Views\MainPage.xaml" />
<None Include="Views\MainPage.xaml" />
<None Include="Views\MainPage.xaml" />
<None Include="Views\MainPage.xaml" />
</ItemGroup>
有人可以解释为什么 MainPage 会出现四次吗?是否需要不止一次,是否需要?有很多文件不在Includes列表中?如果只有一半,那是为什么?
<ItemGroup>
<Compile Update="Views\MainPage.xaml.cs">
<DependentUpon>MainPage.xaml</DependentUpon>
</Compile>
<Compile Update="Views\Home\HomePage.xaml.cs">
<DependentUpon>HomePage.xaml</DependentUpon>
</Compile>
<Compile Update="Views\Cards\Category\CategoryViewCell.xaml.cs">
<DependentUpon>CategoryViewCell.xaml</DependentUpon>
</Compile>
</ItemGroup>
</Project>
我知道有些观点依赖于其他观点,但我有更多这样的观点,但它只显示了三个的关系。为什么会这样?
我能否从项目文件中删除所有这些条目,因为项目文件与项目中的文件夹/文件之间似乎没有太多相似之处?
最佳答案
新的 .csproj
格式有一些基本的变化来简化文件。现在默认包含所有 .cs
(或 .vb
,如果您使用的是 VB.Net)文件。 See here获取更多信息。
您的文件明确包含某些文件和文件夹的原因是您可能在某个时候编辑了文件属性。
Remove
行允许文件成为项目结构的一部分,但不会自动编译或嵌入。
至于为什么多次出现MainPage.xaml
,我也不清楚。要么是 Visual Studio 中的错误添加了它们,要么是源代码管理合并冲突。无论哪种方式,这些重复的行都是多余的,可以删除。
关于C# 项目文件 - 为什么它不代表我项目中的内容?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/51267669/