C
C#8mo ago
AndrewBindon

When I set PublishAot to true, I get "Publish has encountered an error.

When I set PublishAot to true, I get "Publish has encountered an error. We were unable to determine the cause of the error. Check the output log for more details." The log file says: 12/04/2024 18:28:35 System.AggregateException: One or more errors occurred. ---> Microsoft.WebTools.Shared.Exceptions.WebToolsException: Publish has encountered an error. We were unable to determine the cause of the error. Check the output log for more details. --- End of inner exception stack trace --- ---> (Inner Exception #0) Microsoft.WebTools.Shared.Exceptions.WebToolsException: Publish has encountered an error. We were unable to determine the cause of the error. Check the output log for more details. <--- Microsoft.WebTools.Shared.Exceptions.WebToolsException: Publish has encountered an error. We were unable to determine the cause of the error. Check the output log for more details. ===================
22 Replies
leowest
leowest8mo ago
what else do u have selected?
AndrewBindon
AndrewBindonOP8mo ago
<PropertyGroup> <AppendTargetFrameworkToOutputPath>false</AppendTargetFrameworkToOutputPath> <AppendRuntimeIdentifierToOutputPath>false</AppendRuntimeIdentifierToOutputPath> <EnableDefaultItems>false</EnableDefaultItems> <GenerateAssemblyInfo>False</GenerateAssemblyInfo>
<PublishAot>true</PublishAot> <_SuppressWinFormsTrimError>true</_SuppressWinFormsTrimError> <StripSymbols>true</StripSymbols>
<OutputType>Exe</OutputType> <TargetFramework>net8.0-windows7.0</TargetFramework> <RuntimeIdentifier>win-x64</RuntimeIdentifier> <RollForward>Major</RollForward> <ProjectGuid>{47CB82F1-407E-4CC2-8AFD-487200EC0134}</ProjectGuid> <OutputType>WinExe</OutputType> <AppDesignerFolder>Properties</AppDesignerFolder> <RootNamespace>Main</RootNamespace> <AssemblyName>MyProg</AssemblyName> <KniPlatform>Windows</KniPlatform> </PropertyGroup>
leowest
leowest8mo ago
are u using the publish on visual studio? or via cli also your csproj have some inconsistencies not sure how ur not getting warned about it u have 2 OutputType also net8.0-windows7.0?!?! never seen that before is it even working? but I assume u might have a option conflict between your publish in vs and the csproj
AndrewBindon
AndrewBindonOP8mo ago
It builds and runs ok. I only get the error when I try to publish, and again only if I have PublishAot set to true. If I take PublishAot out, then it publishes fine as well. I am using VS community edition for both building and publishing. The net8.0-windows7.0 was created automatically by means of options I chose in the project properties. The only things I added in manually were: <PublishAot>true</PublishAot> <_SuppressWinFormsTrimError>true</_SuppressWinFormsTrimError> I read to do that on some Microsoft page or blog ... see if I can find the reference. But the point is that it doesn't work... just gives me the error.
leowest
leowest8mo ago
well u are using visual studio publish? can u show me the option u choose in the ui @AndrewBindon are u right clicking the project and going to publish?
leowest
leowest8mo ago
No description
leowest
leowest8mo ago
then there are additional options on it I need to see that are not added to the csproj
AndrewBindon
AndrewBindonOP8mo ago
Sorry for delay, do you mean this:
No description
leowest
leowest8mo ago
open cmd go to the folder the csproj file is and try running
dotnet publish -p:PublishProfile=FolderProfile
dotnet publish -p:PublishProfile=FolderProfile
it should give u a better error message
AndrewBindon
AndrewBindonOP8mo ago
Thanks, I'll try that Thank you very much that helped a lot... I am now able to publish to AOT Win_x64 etc. However the resulting compiled .exe appears to be crashing as soon as it is started, and this appears to be happening before it even executes the first line of my code. I'm thinking that it is crashing before the first line of my code, but I suppose it might be crashing ON the first line of my code. In any case, the first thing the app does is write to a debug log, and this is not happening. The App starts and then immediately stops again. Actually I think it may not be even starting... When I look at the task list I don't see it starting and then stopping ... I just don't see it at all. On the assumption that this failing to start is not a consequence of any of the code I've written, I'm wondering how to debug this or troubleshoot the problem. The app runs fine in Debug and Release. It is only when I come to try to publish to AOT Win-x64 and then try to run the resulting .exe that I get this problem. The windows event view says: Exception code: 0xc0000409
AndrewBindon
AndrewBindonOP8mo ago
Stack Overflow
How do you diagnose the exception code 0xc0000409 on Windows?
I have a C++ windows application that was done by another programmer, that I had to remove one line of code. After rebuilding the application with visual studio 2013 it crashes with this in the eve...
AndrewBindon
AndrewBindonOP8mo ago
That's from 2013 but probably still relevant? Apparently I can use DbgHelpBrowser with PDB file to map the relative address where the crash happens back something in the App !
leowest
leowest8mo ago
well I would need information about what your app does potentially some code to understand better the issue like what kind of app it is, i.e.: winforms? console? as I mentioned earlier u have some weird settings in your csproj
AndrewBindon
AndrewBindonOP8mo ago
Hmmm. I found this... I wonder if it might help me?
No description
leowest
leowest8mo ago
no idea, I dont know what your code does there could be many things but without more details its hard to guess, naot for example is very finik in regards reflection
AndrewBindon
AndrewBindonOP8mo ago
I am using KNI which is a derivative of MonoGame. https://github.com/kniEngine/kni
GitHub
GitHub - kniEngine/kni: KNI is a cross-platform C# game framework.
KNI is a cross-platform C# game framework. Contribute to kniEngine/kni development by creating an account on GitHub.
leowest
leowest8mo ago
fairly sure monogame does not support naot yet only one I know that does FNA
leowest
leowest8mo ago
FNA
FNA is a reimplementation of the Microsoft XNA Game Studio 4.0 Refresh libraries.
AndrewBindon
AndrewBindonOP8mo ago
I have built from the same code base to AOT for Android. Not quite the same codebase, most of it is the same.
leowest
leowest8mo ago
well it wont be trivial to figure the issue tell u that much could be something silly it trimmed out, could be some reflection left over u will have to read about naot it look for the things it doesnt like and figure it out sorry I can't be of much help
AndrewBindon
AndrewBindonOP8mo ago
You have helped a lot already ... given me plenty to think about.
leowest
leowest8mo ago
just making sure it all works without naot right if so thean yeah that is what i would look at things that could potentially be breaking naot
Want results from more Discord servers?
Add your server