使用本地化资源构建 DevOps

格森

我正在尝试使用构建解决方案Azure DevOps并将结果发布为私有存储库中的 nuGet 包。

解决方案中的一个项目包含一个Language.resx包含英文文本的本地化资源本地化版本是:Language.da.resxLanguage.se.resx并且Language.no.resx还都未包含在最终的NuGet包。

我尝试/target:Resource,Compile在 DevOps 中添加到 Build Solution 任务的 MSBuild arguments 属性,但它只是导致错误,指出未找到“资源”目标。

我确定我只是遗漏了一些明显的东西,但我就是看不到它。我必须关闭,nuGet 包毕竟已发布,并且可以正常工作,但本地化资源除外。

我检查了生成的 nuGet 包并从相关项目中提取了 dll。打开 dll.Net Reflector 10显示它确实包含英文文本字符串,但没有其他语言。

希望这里的其他人可以帮助我:-)

格森

看来本地化资源确实是默认构建的,尽管在.Net Reflector 10. 原因是它们没有包含在打包任务的 nuGet 包中。

一些研究使我向.nuspec项目添加了一个文件。在这个文件中,我指定了相关文件等,它们现在包含在 nuGet 包中。

但并不理想,因为现在必须手动维护文件和依赖项列表。但我无法找到一种使其动态化的方法。.nu​​spec 文件中的大部分细节都可以通过使用引用该AssemblyInfo.cs文件的变量来实现动态化

我最终在.nuspec文件中得到了以下内容(尽管清除了一些细节,因为它是公开显示的) 注意:该部分Releasesrc属性中的单词files是我的构建配置文件的名称。您的解决方案可能使用不同的名称。

<?xml version="1.0"?>
<package xmlns="http://schemas.microsoft.com/packaging/2013/05/nuspec.xsd">
    <metadata>
        <!-- The identifier that must be unique within the hosting gallery -->
        <id>$id$</id>

        <!-- The package version number that is used when resolving dependencies -->
        <version>$version$</version>

        <!-- Authors contain text that appears directly on the gallery -->
        <authors>$author$</authors>

        <!-- 
            Owners are typically nuget.org identities that allow gallery
            users to easily find other packages by the same owners.  
        -->
        <owners>$author$</owners>

        <!-- License and project URLs provide links for the gallery -->
        <!--<licenseUrl></licenseUrl>-->
        <!--<projectUrl></projectUrl>-->

        <!-- The icon is used in Visual Studio's package manager UI -->
        <!--<iconUrl></iconUrl>-->

        <!-- 
            If true, this value prompts the user to accept the license when
            installing the package. 
        -->
        <requireLicenseAcceptance>false</requireLicenseAcceptance>

        <!-- Any details about this particular release -->
        <!--<releaseNotes></releaseNotes>-->

        <!-- 
            The description can be used in package manager UI. Note that the
            nuget.org gallery uses information you add in the portal. 
            Must be included, and must never be empty.
        -->
        <description>$description$</description>

        <!-- Copyright information -->
        <copyright>$copyright$</copyright>

        <!-- Tags appear in the gallery and can be used for tag searches -->
        <!--<tags></tags>-->

        <!-- Dependencies are automatically installed when the package is installed -->
        <dependencies>
            <dependency id="MicrosoftOfficeCore" version="15.0.0" />
            <dependency id="Microsoft.Office.Interop.Word" version="15.0.4797.1003" />
        </dependencies>
    </metadata>

    <!-- Files to include in the package -->
    <files>
        <file src="bin\Release\$id$.dll" target="lib\net462\$id$.dll" />
        <file src="bin\Release\da\$id$.resources.dll" target="lib\net462\da\$id$.resources.dll" />
        <file src="bin\Release\no\$id$.resources.dll" target="lib\net462\no\$id$.resources.dll" />
        <file src="bin\Release\sv\$id$.resources.dll" target="lib\net462\sv\$id$.resources.dll" />
    </files>
</package>

本文收集自互联网,转载请注明来源。

如有侵权,请联系 [email protected] 删除。

编辑于
0

我来说两句

0 条评论
登录 后参与评论

相关文章