Welcome Guest! To enable all features please Login or Register.

Notification

Icon
Error

Android builds produce garbage Designer.cs file
DeltaEngine
#1 Posted : Saturday, December 2, 2023 7:28:09 PM(UTC)
Rank: Advanced Member

Groups: Registered
Joined: 11/23/2012(UTC)
Posts: 31
Location: Germany

Thanks: 8 times
Was thanked: 3 time(s) in 3 post(s)
Hi, I had this problem already last month and thought it was just a fluke, but it happens on every single Android project in my solution. The manual fix is no good because our build system is also experiencing this issue and I can't constantly modify or delete generated files on the build server obj folder, not very fun ..

So any project with <TargetFramework>net8.0-android</TargetFramework> produces this file in the \obj\Debug\net8.0-android\ folder:
__Microsoft.Android.Resource.Designer.cs

The content looks like this:
//------------------------------------------------------------------------------
// <auto-generated>
// This code was generated by a tool. DO NOT EDIT
// </auto-generated>
//------------------------------------------------------------------------------
using System;

namespace nCrunchTemp_9f7051ca-3ab6-4ede-90cc-857520460535 {
#pragma warning disable IDE0002
public partial class Resource : _Microsoft.Android.Resource.Designer.ResourceConstant {
}
#pragma warning restore IDE0002
}

there are not any special resources, just the standard stuff that gets generated from the Android .NET8 csproj template (values\strings.xml and layout\activity_main.xml plus the icons).

The fix is also easy, the above code obviously doesn't compile because the GUID after nCrunchTemp is not a valid namespace name, changing it to anything else works, there is no code here anyway. It also seems to stay fixes as this file is not generated again until some resource changes happen.
Remco
#2 Posted : Saturday, December 2, 2023 11:46:47 PM(UTC)
Rank: NCrunch Developer

Groups: Administrators
Joined: 4/16/2011(UTC)
Posts: 6,976

Thanks: 931 times
Was thanked: 1257 time(s) in 1170 post(s)
Hi, thanks for sharing this issue.

Right now we don't support Android projects, as these are simply too alien for us to constructively use under NCrunch. I'm actually impressed you were able to get as far as being able to build this project. The later versions of NCrunch generally try to turn off android target frameworks, though I expect this won't happen for projects that aren't multitargeted. The default Android .NET8 project template normally doesn't even build under NCrunch.

The project you're describing seems to be caused by the Android build system choosing to directly use the name of the project when generating namespaces (disregarding other MSBuild properties, like AssemblyName, which are more standard behaviour). This isn't going to be easy for us to directly fix within NCrunch itself.

Assuming ignoring the project under NCrunch isn't an option for you, perhaps you could try running a command line string replacement (i.e. grep) with a regex to rename the bad namespaces? If you put this in a pre-build step for the project, it could prove to be an effective workaround.
DeltaEngine
#3 Posted : Sunday, December 3, 2023 4:58:53 PM(UTC)
Rank: Advanced Member

Groups: Registered
Joined: 11/23/2012(UTC)
Posts: 31
Location: Germany

Thanks: 8 times
Was thanked: 3 time(s) in 3 post(s)
Ok, thanks for the quick response, makes sense. Sorry for not being clearer on my initial post, we have our code separated to shared library code, and then for each platform a project that has all the platform specific stuff (mostly just icons, layout and whatever is the startup). All tests and NCrunch relevant things are in their own test project just referencing the shared library code, so we don't care much about the platform specific projects as long as they compile. But this is exactly the issue, once NCrunch generates that extra file in the \obj\ folder the project won't longer compile unless that file is fixed or deleted. I also noticed today after changing it once and then deleting it, it gets generated correctly again.

We already use ignore the whole project, but I guess sometimes it is already loaded and stuff is generated and then causing the issue, not sure why it happened on the build system as the project was supposed to be ignored and looking at the metrics it is not there. For now it works fine, just next time we add an android or ios project it probably will pop up again, not worth the effort to write script, will fix it manually next time again, but would be nice in the future if nCrunch would not generate .Designer.cs files that don't compile.
Users browsing this topic
Guest
Forum Jump  
You cannot post new topics in this forum.
You cannot reply to topics in this forum.
You cannot delete your posts in this forum.
You cannot edit your posts in this forum.
You cannot create polls in this forum.
You cannot vote in polls in this forum.

YAF | YAF © 2003-2011, Yet Another Forum.NET
This page was generated in 0.030 seconds.
Trial NCrunch
Take NCrunch for a spin
Do your fingers a favour and supercharge your testing workflow
Free Download