0

I am currently performing my 3rd .Net upgrade from .Net4.7 to .Net6.0. The reason I am continually updating from those specific .Net versions is because this is an Optimizely CMS/Commerce web-app upgrade. However, the errors I am experiencing seem to be .Net related so I am posting here instead of an Optimizely specific forum.

To do an upgrade I run the following command:

upgrade-assistant upgrade pathTo/projFile.csproj --ignore-unsupported-features --skip-backup --non-interactive --extension "C:\Temp\EPi.Source.Updater.1.0.32" --target-tfm-support LTS

Once that is complete I massage the .csproj file/utilize the Nuget Package Manager to satisfy dependencies and then I start to fix code errors and determine how to best address areas that need to be re-architected due to changes in .Net.

However, this time around, my compiler is only showing me errors in .cshtml files. This is not the case with the previous .Net6 upgrades I've completed.

I do not like this because there are certain things, such as System.Web.Mvc.WebViewPage<TModel>, which are no longer present in .Net6 that I need to re-architect at a code level before I can fix at a Razor view level.

When I try and figure out how to solve this I've come across a few idiosyncrasies:

  1. When I would open up a .cs file I would get errors like: Predefined type 'System.Object' is not defined or imported

This answer from a related post was the cause (I think). Since then I've been cognizant to not have multiple VS instances running, something I've previously been able to do without issue.

  1. I added the following snippet to my .csproj file to try and get the compiler to build .cs files first:
<PropertyGroup>
    <RazorCompileOnBuild>false</RazorCompileOnBuild>
</PropertyGroup>
  1. I have repaired, then uninstalled, deleted some VS app data files, and reinstalled my IDEs. I used to have VS 2022 Preview as my primary IDE and still had VS 2019 installed. Now both are gone and I just have VS 2022 (non-preview).

  2. I have gone back to our original solution and upgraded it again. This time I updated my .Net Upgrade Assistant. In doing so I had to update my command to the following as the previous one no longer worked: upgrade-assistant upgrade pathTo/projFile.csproj which is slightly annoying because I no longer get the work done by the Epi.Source.Updater extension.

This helped a little, after the command ran, I replaced the .csproj file from my initial upgrade so I didn't have to fix the dependency issues again. The next build I got ~350 code errors! Success, or so I thought. I then replaced the views folder from my old upgrade so that I didn't lose the .cshtml updates my team made while I was trying to figure this out. Then it went back to square one. So, I did a 3rd upgrade and I never got that intermediate build where I was presented with code errors.

So, in the end I feel that my processes were identical yet I got different results each time so I figured I would ask the web and see if you guys have any advice?

zg303
  • 97
  • 1
  • 11
  • Your issue likely stems from inconsistent compilation and multiple VS instances. Quick tips: 1. **Compilation**: Use `false` to compile `.cs` files first. 2. **IDE Setup**: Ensure VS 2022 has all required SDKs. 3. **Cache**: Clear `obj` and `bin` folders. 4. **Extension**: Check for an updated Epi.Source.Updater. 5. **Logs**: Use verbose logs for hidden issues. Consider a minimal example to debug separately. – jimmykurian Aug 24 '23 at 04:10

0 Answers0