Why does Visual Studio only allow one link per file in a project?

时光怂恿深爱的人放手 提交于 2021-01-27 03:53:33

问题


I would like to have a file in several different projects of a solution, however, Visual Studio only allows one link per solution to the file. Is there a way around this?

What is the issue of having several soft links to a single file within a VS project?

Update: I have added the link as described from the comments below, it seems that the issue is on a per project basis. There can not be multiple links to the same file within the project. When I attempt to add the link I receive the following error - "There is already a link to ''. A project cannot have more than one link to the same file."


回答1:


I am using Visual Studio 2008 Professional, and it allows the same file from one project to be soft-linked to every other project, independently of the number of solution files you are using.




回答2:


You could create several links to one file on ONE project, but manually and VS will not show it in project tree.

unload project and add for example links:

<Content Include="..\..\_Common\js\JQuery\jquery.js">
  <Link>Sites\OrgCatalogSite\Design\js\JQuery\jquery.js</Link>
  <CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
</Content>


<Content Include="..\..\_Common\js\JQuery\jquery.js">
  <Link>Sites\TasksManagersSite\Design\js\JQuery\jquery.js</Link>
  <CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
</Content>



回答3:


Not sure what you want to achieve or what kind of file it is, but you could create a new project with that file in it and reference that project from each of the projects that require it? If its a code file, then its will be within scope, if its some other file with "Copy Always" then it will be copied into the various projects bin folder when built?




回答4:


I wish I could add more than one link to the same .XSD/.WSDL file in one project.

In details. The server is in java (WebSphere Application Server/7.0). The client dll in c#. We use contract-first approach.

In Visual Studio 2008 I Add Service Reference. But instead of my original WSDL/XSD contracts it retrieves dummy XService.wsdl and XService_schema1.xsd and generates "not so dev friendly" code (with message wrappers, xFieldSpecified stuff, dummy ArrayOfx collections...). So what I do? I change Reference.svcmap so that it includes exactly original WSDL/XSD contracts and paste them from where they belongs. That's ok, I get dev friendly code and I am happy.

But what if someone changes the server contract? Here I can't just Update Service Reference. I have to copy-paste new contracts to my Service Reference folder any time contract been changed.

To sum up, I need to add my original WSDL/XSD files As Links to all Service Reference folders in order to simplify contract changing process. Just check out new WSDL/XSD, right click Reference.svcmap > Run Custom Tool.

Isn't that worthy feature?



来源:https://stackoverflow.com/questions/1854655/why-does-visual-studio-only-allow-one-link-per-file-in-a-project

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!