We have some .cs files in our project A that are needed in Project B.
First question : how do I share the files across projects without recreating them in the other project?
Second question : if Project A is made in .Net
and Project B is made in .NET Core
, how can we share files without having them to recreate in both projects?
I am using C#
you create cs file in .net project and share the same file in .net core project.
<ItemGroup>
<Compile Include="..\dotnetproject\somefile.cs" Link="somefile.cs" />
</ItemGroup>
https://andrewlock.net/including-linked-files-from-outside-the-project-directory-in-asp-net-core/
It sounds like you are asking for how to add a Linked File reference to a project. If you are using Visual Studio:
Edit: The original post did not specify whether the two projects exist within the same Visual Studio solution, or two entirely separate solutions / repositories / etc. Linked Files as I described above work for sharing files across projects within the same solution.
For projects that exist in two completely different solutions, git repos, etc, a shared common library is the best approach. Since one of the projects is a .NET Core app, the shared library should be an appropriate NETStandard library. NETStandard libraries can be referenced by both Full Framework .NET and .NET Core applications.
For more details, see:
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.