TC Agent with .Net 6 - MVC - NOT Building Views into Application DLL

Going back to (for example) .NET Core 3.1, for an MVC project, the Views are built into their own DLL file which is separate from the main application DLL within the Bin folder. However now within .NET 6, the Views are now built into the same DLL as the application itself.

For internal infrastructure reasons, we have our TC Agents actually on our development machines so whenever TC is run, it's running the publish command on our machine in the background. 

Going back to building our .NET 6 applications, building them either in Visual Studio or indeed using the exact same .NET Publish command on our development machines, compiles the project correctly with the Views inside the main application DLL.

However when we push a build through Team City (which ultimately does the same publish command we can run manually on our development machines), which in turn uses the Agent (i.e. the same development machine) to build, the Views are missing from the application DLL and when trying to run the website, an exception occurs stating it cannot find the Index view.

I really do not seem to understand where the difference is with the Agent doing the Publish command or when I can manually use the Publish command to get differing results in the build folder. This is halting our CI pipeline for any .NET 6 projects now. :(

I am using TeamCity Professional 2022.10.1 (build 116934)

1 comment
Comment actions Permalink
Hi! I would recommend this approach to narrow down the scope of the issue:

In short, create a Command Line build step in TeamCity, and in that step, run the same Publish command as you do locally, outside of TeamCity. It should yield the same result as the local build if the command is the same and run against the same set of sources in the same working dir on behalf of the same user account, etc.

If it works with the Command Line runner, that will give you a workaround. That would also mean that the issue is likely specific to the build runner you used before the Command Line runner. If the results with the Command Line runner are different from the local build, it would mean that the TeamCity agent is getting a different environment or inputs compared to the local build.

Please sign in to leave a comment.