2

We have a project (logging lib) that is used by standard asp.net apps (4.0 framework) and also by sharepoint solutions (3.5 framework).

Is there a way to define both targets so that when we build the project both versions gets built?

Also, as anybody implemented something like this and distribute it via nuget? What's the best approach to publishing both versions on nuget?

Thanks

2
  • 5
    If you do not use 4.0 features why you simply do not release for 3.5? Your lib will be usable both in 3.5 and 4.0! Commented Jun 26, 2012 at 14:43
  • The best way would be to just compile the project twice. Commented Jun 26, 2012 at 14:46

2 Answers 2

2

Answer is <supportedRuntime> config element. This allows you to specify all .NET runtimes your application can support and run under. Of course, in your application you can only use functionalities that all your chosen versions of .NET framework provide.

In short, you should have this in your config:

<configuration>
  <startup>
    <supportedRuntime version="v2.0.50727"/>
    <supportedRuntime version="v4.0"/>
  </startup>
</configuration>

It might be necessary to originally target your application to .NET 3.5 as <supportedRuntime> allows to go up in versions rather than go down.

Sign up to request clarification or add additional context in comments.

Comments

1

You can create two C# projects (csproj files) where you include the same source files (or more projects, depending on your structure). One project should be targeted at .NET 3.5 and the other at .NET 4.0.

If you want to use features specific to .NET 4.0 then you could do it with conditional compilation symbols defined in the .NET 4 project.

Optionally, you could also add one or more solutions (for VS2008 and VS2010), each using one of the C# projects..

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.