IDE:Visual Studio 2019/Water Version:Elements Version 11.0.0.2655 (develop) built on bajor, 20210730-130829. Commit d616582. Target (If relevant): .NET Core Description: When using Visual Studio and trying to compile a project with a PostBuild tag, the build fails. In Water, the same project works just fine.
Expected Behavior: The project compiles and the post build script runs.
Actual Behavior: The project compiles only in Water. In Visual Studio, it fails with the following error:
Build started...
1>------ Build started: Project: SwiftGameCode, Configuration: Debug AnyCPU ------
1>Unhandled Exception:The element <PostBuild> beneath element <Project> is unrecognized. C:\Users\Terrain\Documents\Code\Unity\ElementsUnityTest\SwiftGameCode\SwiftGameCode.elements
1>Error: The element <PostBuild> beneath element <Project> is unrecognized. C:\Users\Terrain\Documents\Code\Unity\ElementsUnityTest\SwiftGameCode\SwiftGameCode.elements
========== Build: 0 succeeded or up-to-date, 1 failed, 0 skipped ==========
Steps:
Create a new elements project
Add a PostBuild script in the project file
Build it in Water, and then in Visual Studio
Additionally, if i put it in a PropertyGroup, the build succeeds in Visual Studio but the script does not run. Visual Studio will complain if i put a Platform on the PostBuild tag in a PropertyGroup.
Here’s the elements project minus unity imports. Since i encountered this while just testing to see if i could use elements with Unity, i can also provide the full unity project and code files if you cannot reproduce with just the elements project.
This project file was originally created with dotnet new classlib and then i used ebuild --convert to convert it to an elements project. That’s because i couldn’t figure out how to create a new class library project in elements directly (it was complaining that there was no main method).
Make sure you have EBuild-style cross-platform compatible scripts; see Pre- and Post-Build Scripts for details. If you edit these in VS, they should automatically be added the correct way.
What do you mean by this? “cross-platform compatible scripts”? Specifying a Platform attribute on the PostBuild tag? If i do that, i get the same error. If i wrap it in a PropertyGroup (which as i noted in my post, allows the project to build in VS without running the script), i then get this error:
Build started...
1>------ Build started: Project: SwiftGameCode, Configuration: Debug AnyCPU ------
1>Unhandled Exception:The attribute "Platform" in element <PostBuild> is unrecognized. C:\Users\Terrain\Documents\Code\Unity\ElementsUnityTest\SwiftGameCode\SwiftGameCode.elements
1>Error: The attribute "Platform" in element <PostBuild> is unrecognized. C:\Users\Terrain\Documents\Code\Unity\ElementsUnityTest\SwiftGameCode\SwiftGameCode.elements
========== Build: 0 succeeded or up-to-date, 1 failed, 0 skipped ==========
(here’s the end of the project file i changed to get that error)
If i put it at the top level, it works in Water. In Visual Studio, i get the following output:
Build started...
1>------ Build started: Project: SwiftGameCode, Configuration: Debug AnyCPU ------
1>Unhandled Exception:The element <PostBuildEvent> beneath element <Project> is unrecognized. C:\Users\Terrain\Documents\Code\Swift\TestNoPostBuild\SwiftGameCode\SwiftGameCode.elements
1>Error: The element <PostBuildEvent> beneath element <Project> is unrecognized. C:\Users\Terrain\Documents\Code\Swift\TestNoPostBuild\SwiftGameCode\SwiftGameCode.elements
========== Build: 0 succeeded or up-to-date, 1 failed, 0 skipped ==========
The reason i had the PostBuildEvent in a PropertyGroup is because that’s necessary in a csproj (or rather, that’s what another project i know works does, not sure if it’s actually necessary), and it did actually get the project to compile in Visual Studio, so i assumed that was more correct than not having it in a PropertyGroup.
FWIW, for tomorrow’s build, i’m adding support for finding this inside an <ItemDefinitionGroup>; which I never heard of before, but apparently is a thing MSBuild supports. I’ll add support for <PropertyGroup> b but according to all in find online, that’s not where they are supposed to go.
according to all in find online, that’s not where they are supposed to go.
In Visual Studio, if you create a C# project from the “Class Library (.NET Framework)” built in template, and then add a post build event as described here, VS will add it in a PropertyGroup at the end of the csproj. I’ll try again on tomorrow’s build then ig.