I have a clean VS 2019 project targeting .NET Framework 4.5 referencing Sitecore.Kernel and Sitecore.ContentSearch packages (specifically v8.0.150812) via NuGet using PackageReference. However, I get build errors in that the Sitecore types or namespaces cannot be found.
This is the project file:
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<TargetFramework>net45</TargetFramework>
</PropertyGroup>
<ItemGroup>
<PackageReference Include="Sitecore.ContentSearch" Version="8.0.150812">
<PrivateAssets>all</PrivateAssets>
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
</PackageReference>
<PackageReference Include="Sitecore.Kernel" Version="8.0.150812">
<PrivateAssets>all</PrivateAssets>
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
</PackageReference>
</ItemGroup>
<ItemGroup>
<Reference Include="System" />
<Reference Include="System.Core" />
<Reference Include="System.Xml.Linq" />
<Reference Include="System.Data.DataSetExtensions" />
<Reference Include="Microsoft.CSharp" />
<Reference Include="System.Data" />
<Reference Include="System.Net.Http" />
<Reference Include="System.Xml" />
</ItemGroup>
</Project>
This is my class:
using Sitecore.ContentSearch;
using Sitecore.ContentSearch.SearchTypes;
namespace TheValley.Sc.Modules.Search.SearchTypes
{
public class CustomSearchResultItem : SearchResultItem
{
[IndexField("_foo")]
public string Foo { get; set; }
}
}
This is what I see in Solution Explorer:
This is the build output:
CustomSearchResultItem.cs(1,7,1,15): error CS0246: The type or namespace name 'Sitecore' could not be found (are you missing a using directive or an assembly reference?) CustomSearchResultItem.cs(2,7,2,15): error CS0246: The type or namespace name 'Sitecore' could not be found (are you missing a using directive or an assembly reference?) CustomSearchResultItem.cs(6,43,6,59): error CS0246: The type or namespace name 'SearchResultItem' could not be found (are you missing a using directive or an assembly reference?) CustomSearchResultItem.cs(8,10,8,20): error CS0246: The type or namespace name 'IndexFieldAttribute' could not be found (are you missing a using directive or an assembly reference?) CustomSearchResultItem.cs(8,10,8,20): error CS0246: The type or namespace name 'IndexField' could not be found (are you missing a using directive or an assembly reference?)
It is necessary for me to reference Sitecore 8.0 packages. No other restrictions. Any assistance greatly appreciated.