I am extending the build process of my project to include generation of new source file from various models (
Thrift IDL
and others). I use C# with Visual Studio 2012.
我正在扩展我的项目的构建过程,以包括从各种模型(Thrift IDL和其他)生成新的源文件。我在Visual Studio 2012中使用C#。
The generation logic is done by extending BeforeBuild
target in .csproj
file as the following:
生成逻辑是通过在.csproj文件中扩展BeforeBuild目标来完成的,如下所示:
<ItemGroup>
<Thrift Include="IDL\*.thrift" />
</ItemGroup>
<Target Name="BeforeBuild">
<RemoveDir Directories="$(gendirs)"/>
<MakeDir Directories="$(gendirs)" />
<XmlPeek XmlInputPath="@(MSBuildProjectDirectory\app.config" Query="/configurations/appSettings/add[@key='ThriftCompilerPath']/@value">
<Output TaskParameter="Result" ItemName="ThriftExec"/>
</XmlPeek>
<Exec Command="$(ThriftExec) -v -out Gen\Thrift --gen csharp:hashcode %(Thrift.FullPath)" />
...
</Target>
The .thrift
files are part of the project and are in UTF-8 format which seems to be an issue since the thrift compiler (and others) are not able to process UTF-8 formats and expect only ASCII. Feeding these files to the compiler causes errors.
.thrift文件是项目的一部分,采用UTF-8格式,这似乎是一个问题,因为thrift编译器(和其他人)无法处理UTF-8格式并且只能使用ASCII格式。将这些文件提供给编译器会导致错误。
Is there a way such that the files are either saved in ASCII format or at least converted to ASCII format before feeding them to their corresponding compilers using msbuild? I think this is possible by deriving Task class but I am looking for hopefully simpler solutions.
有没有办法使文件以ASCII格式保存或至少转换为ASCII格式,然后使用msbuild将它们提供给相应的编译器?我认为这可以通过派生Task类来实现,但我正在寻找希望更简单的解决方案。
1 个解决方案
#1
1
Thrift understands UTF-8.
Thrift了解UTF-8。
Until recently there was a problem with the BOM preceding some UTF-8 files, so if you store the Thrift IDL file without the BOM, it will work. The problem is known and already fixed in the Trunk.
直到最近,某些UTF-8文件之前的BOM存在问题,因此如果您存储没有BOM的Thrift IDL文件,它将起作用。问题已知并已在Trunk中修复。
Does that solve your problem?
这会解决你的问题吗?
#1
1
Thrift understands UTF-8.
Thrift了解UTF-8。
Until recently there was a problem with the BOM preceding some UTF-8 files, so if you store the Thrift IDL file without the BOM, it will work. The problem is known and already fixed in the Trunk.
直到最近,某些UTF-8文件之前的BOM存在问题,因此如果您存储没有BOM的Thrift IDL文件,它将起作用。问题已知并已在Trunk中修复。
Does that solve your problem?
这会解决你的问题吗?