对于F#类型提供程序,如何使相对路径作为静态参数起作用?
问题描述:
有没有一种好的方法可以使编程时的类型提供程序和构建时的msbuild的相对路径都起作用?
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">
答
您可以使用#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.