简体   繁体   中英

Unity .NET - Using a project runs well, using its template messes dependencies up

Long story short: I am trying to develop a mod for Enter the Gungeon and other devs gave me a ZIP of a simple mod VS project with all dependencies solved, ready to be compiled and idiot-proof. When I export the project as a template and create a new project using it, references are lost and the code won't compile.

Using the original project:

  • Screenshot of the main code as given by those devs (no errors displayed):

原始代码的屏幕截图,没有任何变化

  • Screenshot of the references folder (everything working):

参考部分的屏幕截图

When I press the compile button it runs perfectly. I can edit whatever I want that the project runs and compiles as expected. However, I didn't want to use that concrete ZIP whenever I was going to develop a new mod.

Where I use the template, problems start coming

My idea was to export the project as a template and select the template when creating a new mod using the new solution option. However it looks like VS looses some files on the way...

  • The project created from the template generates errors (this template is supposed to be a carbon copy of the original project, isn't it?):

从模板创建项目时的原始代码截图

  • And the references section from the new project show a lotta warnings (also created from the template of the original project):

引用的屏幕截图现在显示很多警告

As you can see, if we create a project from the template that is based on the original project the libraries aren't defined and some references show warnings (although hovering on them doesn't show anything).

I've already tried to do some cheating by copying the .vstemplate file from the template to the original project (plus putting the files into a zip) and not even that way the problem is solved.

What would you do or think of?

^^.

Dependencies can be annoying, but generally that warning symbol around at each dependency means it cant find them.

So, you should edit the csproj file (right click the file named "prueba dependencias" and click "edit project file") then look for the Reference tags. Make sure the HintPath tags point to a file. If they don't, then you can do one of two things: Change the content of the tag to point to a real file or create a dummy file where the path points.

Alternatively, you can remove all the dependencies it cant find, right click "Referencias", then "Add reference" and all the ones you removed back.

That should (hopefully) fix your issues.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM