Does Designer support Microsoft.NET.Sdk project format?

Posts   
 
    
Vitaly L
User
Posts: 6
Joined: 22-Jul-2020
# Posted on: 07-Oct-2020 14:51:34   

Hi,

I'm trying to move all projects in my solution to Microsoft.NET.Sdk format. After migrating the Data project (generated by LLBLGen) and re-generating entities I faced following error:

Microsoft.NET.Sdk.DefaultItems.targets(269, 5): [NETSDK1022] Duplicate 'Content' items were included. The .NET SDK includes 'Content' items from your project directory by default. You can either remove these items from your project file, or set the 'EnableDefaultContentItems' property to 'false' if you want to explicitly include them in your project file. For more information, see https://aka.ms/sdkimplicititems.

This error occuer because Designer adds Compile Include nodes (just like in example below) into project file:

<Compile Include="EntityClasses\Entity.cs">
      <GeneratedBy>LLBLGen Pro</GeneratedBy>
</Compile>

It looks like designed does not takes into account project format while generating the code. I'd expect it to add Complie Update in case it operates with a project in Microsoft.NET.Sdk format:

<Compile Update="EntityClasses\Entity.cs">
      <GeneratedBy>LLBLGen Pro</GeneratedBy>
</Compile>

Is there any workaround for this? Maybe I've missed something?

Walaa avatar
Walaa
Support Team
Posts: 14946
Joined: 21-Aug-2005
# Posted on: 07-Oct-2020 19:18:15   

Did you try to generate the code for .NET Standard in an empty directory?

If this doesn't work, please specify the Designer version (release date) that you are using?

vskurikhin
User
Posts: 1
Joined: 02-Jun-2020
# Posted on: 08-Oct-2020 07:36:35   

Thank you for the response. I'm working with Vitaly L, and I can provide some update on this.

1) Your suggestion works. If I remove the existing project file and generate the code for .NET Standard, the new project file looks nice and plain.

<?xml version="1.0" encoding="utf-8"?>
<Project Sdk="Microsoft.NET.Sdk">
  <PropertyGroup>
    <TargetFramework>netstandard2.0</TargetFramework>
    <AssemblyName>Data</AssemblyName>
    <RootNamespace>Data</RootNamespace>
  </PropertyGroup>
  <ItemGroup>
    <PackageReference Include="SD.LLBLGen.Pro.ORMSupportClasses" Version="5.6.0" />
  </ItemGroup>
</Project>

2) Our case is a bit more complicated. First, we're still on .NET Framework 4.8. Second, there's some additional info in our Data.csproj file (properties, references, includes) that we'd like to keep on every update of the generated code. I played with the code generation a bit and found out that the only crucial part is this one

   <PropertyGroup>
    <ProjectGuid>{E9DB475C-34FF-496E-A174-0E9D169BBB67}</ProjectGuid>
   </PropertyGroup>

If ProjectGuid property is present, the Designer treats the project file like being in old format, despite of <Project Sdk="Microsoft.NET.Sdk"> tag and .NET Standard 2.0 platform selected, and it adds <Compile Include=...> records for the generated files.
If ProjectGuid property is removed, the code generation works as expected, even for .NET Framework 4.8 platform. Btw, we're using version "5.6 (5.6.1) RTM".

I think, this one is solved. Thank you again.

Otis avatar
Otis
LLBLGen Pro Team
Posts: 39590
Joined: 17-Aug-2003
# Posted on: 08-Oct-2020 09:40:43   

vskurikhin wrote:

2) Our case is a bit more complicated. First, we're still on .NET Framework 4.8. Second, there's some additional info in our Data.csproj file (properties, references, includes) that we'd like to keep on every update of the generated code. I played with the code generation a bit and found out that the only crucial part is this one

   <PropertyGroup>
    <ProjectGuid>{E9DB475C-34FF-496E-A174-0E9D169BBB67}</ProjectGuid>
   </PropertyGroup>

If ProjectGuid property is present, the Designer treats the project file like being in old format, despite of <Project Sdk="Microsoft.NET.Sdk"> tag and .NET Standard 2.0 platform selected, and it adds <Compile Include=...> records for the generated files.
If ProjectGuid property is removed, the code generation works as expected, even for .NET Framework 4.8 platform. Btw, we're using version "5.6 (5.6.1) RTM".

Thanks for the feedback. Any reason the projectguid was present in the csproj in the new format ?

Our code generator updates csproj files but never overwrites them, hence it tries to update an existing one. It checks to see what format it is in, and if it finds some elements which aren't in new csproj files it decides it's the old format so it will emit the file elements.

Frans Bouma | Lead developer LLBLGen Pro
Vitaly L
User
Posts: 6
Joined: 22-Jul-2020
# Posted on: 09-Oct-2020 14:18:51   

Otis wrote:

Any reason the projectguid was present in the csproj in the new format ?

There were no particular reasons. We decided to get rid of it.

Thanks for your help simple_smile