Open FabioSilvaOS opened 1 month ago
For the record, I'm not sure if this is a fix or a workaround, but I found if I put in client proj file:
<EnableDefaultCompileItems>false</EnableDefaultCompileItems>
this bug disappears.
I had hoped that the bug bug had been resolved in #229 where the includes are configured to remove duplciates, previously I often did something similar to below in order to avoid the problem , it might work for you
From "AspNetCore.Client.CodeGen.csproj" sample project:
<ItemGroup>
<Compile Remove="Generated_Code\AspNetCore.Hosting.AspNetCore.g.cs" />
<None Include="Generated_Code\AspNetCore.Hosting.AspNetCore.g.cs" />
</ItemGroup>
Or just add disable EnableDefaultCompileItems and add <Compile Include="**/*.cs" Exclude="Generated_Code/**;obj/**;bin/**" />
If you have any suggestion of how this could be fixed in https://github.com/OpenRIAServices/OpenRiaServices/blob/main/src/OpenRiaServices.Tools/Framework/build/OpenRiaServices.Client.CodeGen.targets feel free to create a PR
@Daniel-Svensson I checked output build logs, and I think maybe it could not remove duplicates because, for example, one item is pointing to
Generated_Code\CsServer.g.cs
and other is pointing to
C:\tmp\RiaBug\CS\CsClient\Generated_Code\CsServer.g.cs
same file, but one path is relative and other absolute.
I will try check for a solution, but I need to finish my deadlines first and, for now, EnableDefaultCompileItems
was enough :smile:.
That sounds promising. It should hopefully be solvable by converting/normalizing the paths from the openriaservices task between full and relative paths (so they match default item includes).
I think I have seen such functionality built into msbuild.
Good luck with the deadline and in the meantime, the workaround is documented here.
Note:
EnableDefaultCompileItems
uses relative paths.
Changing the paths to relative would probably solve the "duplicate" issueIt is possible to make paths from openria code generation relative either in code or using https://learn.microsoft.com/en-us/visualstudio/msbuild/property-functions?view=vs-2022#msbuild-makerelative
Describe the bug With the attached projects (RiaBug.zip), the SERVER project builds correctly, and the CLIENT projects build correctly, and correctly creates the generated files the FIRS TIME. For C#, the 2nd time we got a warning, and from 3rd time we do not have problems. But with VB.Net, the second time we got errors and the projects does not build anymore. You can try in Visual Studio, but to avoid IDE quirks I tested in command line. just go to desired project folder and execute
dotnet build
. After the problem arises (for VB.Net), the only one way to build again is performingdotnet clean
and thendotnet build
. But when you build again the problem returns.Summary: For C#
warning CS2002: Source file 'C:\tmp\RiaBug\CS\CsClient\Generated_Code\CsServer.g.cs' specified multiple times
For VB:
To Reproduce I added this repro in zip, but it is very very simple, I saw that problems in a big project, and then I created a MRE to test RiaBug.zip
The server project file (same for vbproj and csproj):
The server Program.cs file:
The server Program.vb file:
The client just need the proj file:
Expected behavior Every time the client project needs to build correctly
Nuget package and version
EDIT The same happens if I use
OpenRiaServices.Client
instead ofOpenRiaServices.Client.Core
+OpenRiaServices.Client.CodeGen