Sharing assets (images/css/js) between projects us

2019-02-19 01:43发布

Is there an effective way to share visual assets between different projects?

This would include images, CSS and JavaScript.

I've looked at the following Stack Overflow questions which don't seem to answer this:

We make use of TFS, not sure if that might have something we can use?

3条回答
干净又极端
2楼-- · 2019-02-19 02:03

There's nothing built-in ASP.NET MVC that will allow you to generate links to other ASP.NET applications. All the helpers work with relative controller actions for the current application. If all your static files are located inside another ASP.NET application (a sort of custom CDN) then you could define the base location of this application in your web.config and then build custom helpers that will serve those resources:

@Html.Resource("/foo.js", "text/javascript")

and the custom helper will generate an absolute url to this external resource.

查看更多
神经病院院长
3楼-- · 2019-02-19 02:19

A handy solution is to create a "Solution folder" as shown in Erik Philips's solution.

Basically "Solution folder" is just a common share folder created in your solution that contains all shared files, then you refer these files in your project(s) as links. For all practical purposes these share files could be used in your site(s) as if they were present in your local site folder.

查看更多
做个烂人
4楼-- · 2019-02-19 02:23

I have been struggling with this same problem, and I found that the best solution for me was simply to create a "holder" project for the assets files, and with the help of pre-build events just copy all the files into the projects that require them. This way you just need to edit them in the "holder" project, but they will always be in-sync as long as you dont touch them in the other projects.

查看更多
登录 后发表回答