Project fails to build after upgrading version of Unity - c#

Our Unity project has recently been upgraded from 2017.3.1f1 to 2018.3.2f1. (I realise we are still behind the latest, but we're hoping to upgrade to latest shortly)
After the upgrade, the game builds fine in Unity (no errors) and plays perfectly.
However, in Visual Studio the project fails to build with 167 errors.
These errors are not related to the games files but other projects that seem to have been automatically added to the solution.
The following projects are causing us concerns:
Unity.Analytics.DataPrivacy
Unity.CollabProxy.Editor
Unity.PackageManagerUI.Editor
Unity.TextMeshPro
Unity.TextMeshPro.Editor
All of the errors relate to source files not being found. None of the above projects have any scripts within their project. The errors are, for example:
Error CS2001 Source file '[Path to Project]\Packages\com.unity.collab-proxy\Editor\Collab\Presenters\CollabHistoryPresenter.cs' could not be found. Unity.CollabProxy.Editor
I have checked the above file path and the file it was looking for isn't there. However, I didn't remove it.
None of these projects were present in solution explorer before upgrading versions and the project built fine.
I have tried removing these projects which solved the immediate problem. However, relaunching Visual Studio re-adds them.

Have you tried to build a fresh visual studio solution while deleting the old one?

Project in question is on hold. I started a new project in Unity 2019 and this issue remained. Therefore I was aware this wasn't a project issue but more environmental.
After looking across the internet I discovered this thread:
https://forum.unity.com/threads/error-building-project-with-visual-studio-in-unity-2018-unity-package-source-file-not-found-error.530766/
Upgrading to the latest version of Visual Studio 2017 has resolved the issue. Although judging from the thread above, upgrading to 2017 15.9.5 resolved the issue for a lot of people.

Related

Why does my release build fail with error APPX0002: Task 'ValidateAppxManifest' failed?

I am trying to develop a UWP app for Windows desktop machines. Everything has been going well, but within the last few days I've lost the ability to build a release version (building a debug version still works fine).
I get the following error messages:
1>C:\Program Files (x86)\Microsoft Visual Studio\2019\Community\MSBuild\Microsoft\VisualStudio\v16.0\AppxPackage\Microsoft.AppXPackage.Targets(2810,5): error APPX0002: Task 'ValidateAppxManifest' failed. Unspecified error
1>C:\Program Files (x86)\Microsoft Visual Studio\2019\Community\MSBuild\Microsoft\VisualStudio\v16.0\AppxPackage\Microsoft.AppXPackage.Targets(2810,5): error APPX0002: [My App] violates pattern constraint of '\bms-resource:.{1,256}'.
I've tried a number of "fixes" that worked for people over the last few years. Some people report the problem fixed itself in the latest version of Visual Studio. Unfortunately, the versions they mention are older than the version I'm using, which is
Microsoft Visual Studio Community 2019
Version 16.6.3
Many fixes from the net are similar to the ones below, from the URL
https://social.msdn.microsoft.com/Forums/en-US/4cc2cbfb-fa0d-4f12-a0a1-9072d78e26d6/vs2019-error-task-validateappxmanifest-failed-unspecified-error-again-and-again?forum=msbuild
One fix was:
Clear nuget packages,
Clean solution
Close VS
Delete bin & obj folders of the main (startup) project
Open VS - solution
Restore solution nuget packages
Rebuild 'n go
Another fix was:
uninstalling vs & sdks,
removing every nuget folder,
clean the registry and restart the system,
the last step once more,
reinstall vs.
I have tried all of these (several times) except for "clean registry." I'm not sure what part of the registry we're talking about.
So, has anyone overcome this problem in a different way, or know what the registry idea is?
Oh, some other data is
Maybe my machine is too old (about 6 years old). I’m speculating that even if my machine seems to have the latest version of Windows an Visual Studio, maybe it doesn’t have exactly the latest code.
Things went bad while I was adding two new features. The first was to ask the user for a rating, via _storeContext.RequestRateAndReviewAppAsync(); The second was allowing the user to share some data via DataTransferManager.ShowShareUI();
I was thinking maybe these APIs might require some declarations in the manifest that I don't have, but I don't see from the documentation that they do.
Any ideas would be greatly appreciated. I’m out of ideas at the moment.
Dan
Here is the answer, for me. I’m not confident that this as the answer for all cases, but all is good now.
You may remember that I said I had the latest version of Windows, and I did. However, when I checked with Windows Update last night, it confirmed I was “up to date” but it offered me a “Feature update” to Windows 10, version 2004. I decided to go for it.
The update took hours to complete, and this morning it was still only 94% complete when Nico Zhu suggested to try using Visual Studio 2017. I figured I’d install VS 2017 after the update, but when it was finally complete, I decided to try VS 2019 one more time with my fresh new version of Windows. Amazingly, it worked the first time.
I should mention that my new procedure for making an app package now includes
close VS 2019
delete the project’s obj folder
delete the project’s bin folder (I used to just delete the obj folder, but after seeing others suggestions I’ve added this step)
launch VS 2019
create the App Package
I wanted to do another build/package so I fixed a couple of cosmetic bugs and tried again. On the second try I fell back into my old pattern and I did NOT delete the bin folder. Immediately VS 2019 popped up with an error message something like “Cannot complete build. Fix problem with your app manifest.” Rather than pouring over the manifest file as I’ve been doing for the last couple of days, I deleted both the obj and bin folders and tried again. The build/package process then worked perfectly.
So, I want to say that the app manifest file was not the culprit (in this case anyway) and I’m now a fan of deleting both the obj and bin folders, and having Win 10 version 2014, before attempting a release build with VS 2019.
Dan

Missing namespaces on new Visual Studio extension development installation

I need to change an existing Visual Studio 2017 extension development project. This project has everything set up just fine. However in three different computers I tried to install the necessary frameworks to build it as is and in only one of them I actually worked without issues.
I go to my Visual Studio installer and modify it by adding the workload for "Visual Studio extension development", I then open up the project and noticed a bunch of compile errors due to missing namespaces. I thought that maybe the references weren't set up properly so I went looking for what I need to add. However I can't find neither online or by browsing the libraries already in the system the ones I'm supposed to add. Even weirder is that I tried doing this in three different computers an in one of them it worked correctly without ever changing anything.
The following image is just an example of the libraries I'm missing:
I can't figure out for the life of me what am I missing here, supposedly these should be in the Visual Studio SDK that is installed with Visual Studio installer yet my system can't find it? I tried adding more workloads and components, tried uninstalling and installing again and nothing works and I can't find a single search result with this problem. Why would this work once out of three times with the exact same steps?
#magicandre1981 pretty much solved it for me. Installing that microsoft.visualstudio.editor nuget package installed almost all other dependencies as well with only other two missing that I found the reference online.
Since I actually tried it before with no success I now believe the reason that it was not working before was due to not picking the correct version like magicandre mentioned.

Script# - type or namespace name 'ScriptAssemblyAttribute' could not be found

I have a template project that uses Script# (downloaded from here: https://github.com/scottdurow/SparkleXrm). I've built and deployed this many times so not sure if this is an environmental issue or a version issue. I stripped the solution right down to 2 projects - ClientUi (which references Script#) and a CRMPackage where my HTML page is, but when I build I get the error:
The type or namespace name 'ScriptAssemblyAttribute' could not be found
...and I can't get rid of it. I'm on VS 2017, Windows 10, Project version is .net 4.0 (have tried changing it to 4.5, same problem).
Have tried reapplying Script# via NuGet, but it's just not happy with me and keeps throwing the error. Have tried clearing VS cache, cleaning the build and restarting visual studio, standing on my head, drinking wine, nothing seems to work. In fact I think the wine made it worse.
Help.
For future people hitting this, it's a Visual Studio version issue. Preview 2 broke ScriptSharp compilation. It's something to do with a mismatch in mscorlib versions.
https://developercommunity.visualstudio.com/content/problem/138986/1550-preview-2-breaks-scriptsharp-compilation.html
As per the above link, the fix is setting the following flag in the MSBuild project file:
<DisableHandlePackageFileConflicts>true</DisableHandlePackageFileConflicts>

Lost references in Visual Studio 2017 solution

I've been working on a project with a coworker and we're using Visual Studio 2017 as IDE and also Git to push the versions to VS repository. We had a few problems and decided to start a new project in Visual Studio with the content we already had.
The weird thing is: when cloned the repository to my computer and synched, some of the references were lost. A yellow triangle appears next to the lost references icons in Solution Explorer, and it doesn't have a path set like the ones that work. Also, inside Source > Repos, the project folder has all files, including the ones that are missing. I tried deleting the project and cloning it again, tried to download only the .zip file and starting the project offline, and also running VS 2017 as administrator (it appears this solved similar problems for others before) and nothing worked. My coworker (who pushed the project to the repo in first place) can compile normally and is not facing this reference problem.
Has anyone ever experienced this issue?
We're using VSTS with a git repository, and this happens all the time, especially when pulling updated solutions. I find a clean and rebuild fixes the problem.
You can run in the Package Manager Console the following command to clean up the nugget packages:
Update-Package -reinstall -ProjectName XYZProjectName
or run it for the whole solution:
Update-Package -reinstall
In my case after a merge with the master branch, I had conflicts in the project file (.csproj). When resolving the issue VS2019 automatically had unloaded the project file where those conflicts were and I didn't notice. A check for that might save time for someone.
I once experienced it when I was having a Visual Studio 2015 project open and then pulling new git commits. The new project I was pulling was was set up for Visual Studio 2017 though.
So my VS 2015 was open and dsiplaying the now VS 2017 project. I believe it only contained one nuget package, however this was not downloaded correctly and instead the package was displayed as a missing file.
Maybe this is happening for you too?
Same problem in VSC 2021 version 1.63.
Solution - Removed project folder from workspace:
CTRL+Shift+P, search for and execute the
"Workspace: Remove Folder from Workspace" command.
Then reopened the project folder and was OK

Visual Studio throws errors when attaching to Unity

All of a sudden when I try to attach to Unity 5.2 with Visual Studio 2015 I get a bunch of errors as seen in screenshot below. This is the second this has happened this week. Last time I had to create a new project and bring everything over to resolve the issue. Unity plays fine, no errors...but visual studio throws errors when I try to attach. It worked earlier this evening.
Few things to consider when project shows error while being fully functional in Unity3D Editor itself:
Can you build your project in Visual Studio even if errors are shown? If so, there is possiblity that these are just leftovers from Unity3D building your project - should disappear on first successful build from VS
If you can't build your project, have you tried to remove your Library folder from project's root folder? In many cases it will fix the problem but will end up in forcing Unity3D to rebuild some of the files it had previously in Library folder.
Have you added any new libraries (dll's) to project? Any chance they might be installed/added in a wrong way? If so, try readding them to project (if it's a classic dll) or readd plugin that you have troubles with.
I would leave version incompability as it would end up with errors in Unity3D console. Same with errors with solution per se.
When I changed target framework to Unity 3.5 .net full Base Class Libraries the build errors went away.
I found the solution posted by Nathan Koop here: Type or namespace name does not exist

Categories

Resources