问题
Is there a good way to make a relative path work for both the type provider while programming and msbuild while building?
//type AddressBookProto = Froto.Gen.ProtoGen< @"test\addressbook1.proto"> // VS GUI
//type AddressBookProto = Froto.Gen.ProtoGen< @"..\test\addressbook1.proto"> // Build
type AddressBookProto = Froto.Gen.ProtoGen< @"C:\Users\taggartc\froto\froto\test\addressbook1.proto">
回答1:
You could use #if
#if DEBUG //or similar constant
type AddressBookProto = Froto.Gen.ProtoGen< @"test\addressbook1.proto">
#else
type AddressBookProto = Froto.Gen.ProtoGen< @"..\test\addressbook1.proto">
#endif
Now you just need to define appropriate conditionals.
来源:https://stackoverflow.com/questions/13466957/for-an-f-type-provider-how-do-i-make-a-relative-path-work-as-a-static-paramete