-1

So I have a project inside a huge solution.

My project is .NET 3.5 and the rest of the solution is 4.7.1. My goal is that if someone else tries to update my project from 3.5 it will fail to compile.

tl;dr

  1. How do I read the .net version of a project?
  2. How do I conditionally fail a compilation?
Uwe Keim
  • 39,551
  • 56
  • 175
  • 291
Danw25
  • 306
  • 2
  • 13
  • 5
    *Why* would you want to do this? You could use conditional compilation though – Camilo Terevinto Jan 10 '18 at 12:05
  • 1
    If they are updating the framework version then there's probably nothing you can do in code that they couldn't override/delete anyway – phuzi Jan 10 '18 at 12:08
  • 3
    You'd rather devote an unknown amount of time to *preventing someone from performing what will, in time, be inevitably required*, rather than spend an unknown amount of time fixing whatever issues currently mean that the project shouldn't be upgraded? – Damien_The_Unbeliever Jan 10 '18 at 12:08
  • no choice in the matter, its a dll that interacts with 3rd party software that i have no control over. medical imaging is fun! also, i don't understand why the duplication since i clearly didn't know about conditional compilation for .NET versions but i got my answer so yay – Danw25 Jan 12 '18 at 07:44

1 Answers1

2

Use conditional compilation like this

#if !NET35
#error This project requires .NET 3.5 framework
#endif
Hans Kilian
  • 18,948
  • 1
  • 26
  • 35