开发者

MSBuild - Nest an external file (file outside of the project folder) into a file in the project folder

开发者 https://www.devze.com 2023-03-09 07:59 出处:网络
I have the following scenario: I have 2 projects: Proj1 Proj2 Each of these projects needs access to a similar service (FooService) so I wrote up the Foo.svc and Foo.svc.cs files and put them in

I have the following scenario:

I have 2 projects:

  • Proj1
  • Proj2

Each of these projects needs access to a similar service (FooService) so I wrote up the Foo.svc and Foo.svc.cs files and put them in a directory that was outside of both 开发者_Go百科of the project directories.

I then edited my Proj1.csproj file to do the following:

Foo.svc

This works fine in terms of editing and compiling the code, however I can't access the service: http://localhost/Proj1/Foo.svc << This does not exist (because the actual Foo.svc file is not in the Project directory).

So instead I copied the Foo.svc file inside each of the Projects and just left the code-behind file (Foo.svc.cs) in the common directory. However, now Visual Studio complains that "The parent file, 'Foo.svc', for file '..\Common\Foo.svc.cs' cannot be found in the project file. Probably because it is looking for the 'Foo.svc' file relative to the code-behind file?

Foo.svc

Is there any way to do what I'm looking for... keeping the code-behind outside of both project directories (so they can both link to it) and somehow have svc files that are accessible in my IIS on localhost and have it so that the code-behind file folds into the svc file in Visual Studio?


What you're talking about is altering your MSBuild file (also known as a csproj file - http://msdn.microsoft.com/en-us/library/bb629388.aspx)

I tried to simulate what you're doing and I don't think there is a solution that would fit what you want. You're right, your project will work just fine, but aesthetically you can't have a file external to the project directory nested to a file inside of the project directory.

0

精彩评论

暂无评论...
验证码 换一张
取 消