我在项目外的某个地方有2个原始文件。
common \ v1 \ timestamp_offset.proto
syntax = "proto3";
import "google/protobuf/timestamp.proto";
import "google/protobuf/duration.proto";
package common.v1;
message TimestampOffset
{
google.protobuf.Timestamp timestamp = 1;
google.protobuf.Duration offset = 2;
}
booking \ v1 \ booking.proto
syntax = "proto3";
import "google/protobuf/empty.proto";
import "common/v1/timestamp_offset.proto";
package booking.v1;
message Booking{
int32 id = 1;
int32 carrier_id = 2;
int32 customer_id = 3;
string booking_type = 4;
string travel_type = 5;
common.v1.TimestampOffset time = 6;
}
我需要将文件链接到项目中以使用它们。使用此类选项将不起作用。我收到未找到导入“ common / v1 / timestamp_offset.proto”或出现错误。
<ItemGroup>
<Protobuf Include="..\Protos\booking\v1\booking.proto" Link="booking\v1\booking.proto"/>
<Protobuf Include="..\Protos\common\v1\timestamp_offset.proto" Link="common\v1\timestamp_offset.proto"/>
</ItemGroup>
我发现。如果我将两个文件都移到项目中,一切都会好的。
<ItemGroup>
<Protobuf Include="booking\v1\booking.proto"/>
<Protobuf Include="common\v1\timestamp_offset.proto"/>
</ItemGroup>
除Include
etc外,该<Protobuf>
元素还允许您指定一个ProtoRoot="something"
属性,该属性用于在解析导入等时指定根。这可能是您所缺少的。这是记录在这里
本文收集自互联网,转载请注明来源。
如有侵权,请联系 [email protected] 删除。
我来说两句