MSBuild 不解析路径内的参数
MSBuild Not Resolving Parameters inside Path
我必须 运行 使用 ms 构建的文本转换文件,所以我使用 Transform 作为目标。为了在我的项目中 运行 它,我必须传递一些路径来获取资源 dll。所以我的命令是
D:\WorkSpace\Projects\Client\Dev\Project\Lw.Domain.Project>msbuild /tv:15.0 /t:transform /p:TransformFile="ProjectEntityModelGenerator.tt" /p:SolutionDir=".." /p:FrameworkVersion=4 /p:MetaModelFolder="$(SolutionDir)\packages\LW.Framework$(FrameworkVersion)" /p:BaseResourceFolder="$(SolutionDir)\packages\LW.Framework$(FrameworkVersion)" /p:FrameworkReference="package" /p:IsFromMSBuild="true"
但它没有解析路径,所以我遇到如下问题,
C:\Program Files (x86)\Microsoft Visual
Studio17\Professional\MSBuild\Microsoft\VisualStudio\v15.0\TextTemplating\Microsoft.TextTemplating.targets(340,5):
error : System.IO.FileNotFoundException: Could not find a part of the
path
'D:\WorkSpace\Projects\Client\Dev\Project\Lw.Domain.Project$(SolutionDir)\packages\LW.Framework$(FrameworkVersion)Lw.System.Metamodel.dll'.
[D:\WorkSpace\Projects\Client\Dev\Project\Lw.Domain.Project\Lw.Domain.Project.csproj]
我的 csproj 文件中是否遗漏了什么?下面是我的csproj文件配置,
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
<PropertyGroup>
<!-- Get the Visual Studio version – defaults to 10: -->
<VisualStudioVersion Condition="'$(VisualStudioVersion)' == ''">10.0</VisualStudioVersion>
<!-- Keep the next element all on one line: -->
<VSToolsPath Condition="'$(VSToolsPath)' == ''">$(MSBuildExtensionsPath32)\Microsoft\VisualStudio\v$(VisualStudioVersion)</VSToolsPath>
<SolutionDir>$(SolutionDir)</SolutionDir>
<FrameworkVersion>$(FrameworkVersion)</FrameworkVersion>
<MetaModelFolder>$(SolutionDir)\packages\LW.Framework$(FrameworkVersion)\</MetaModelFolder>
<BaseResourceFolder>$(SolutionDir)\packages\LW.Framework$(FrameworkVersion)\</BaseResourceFolder>
<IsFromMSBuild>$(IsFromMSBuild)</IsFromMSBuild>
<ComputedSolutionDir>$([System.IO.Path]::GetFullPath($([System.IO.Path]::Combine($(ProjectDir),"..\"))))</ComputedSolutionDir>
<DomainResourceFolder>$(SolutionDir)..\Product\Lw.Domain\bin$(Configuration)\</DomainResourceFolder>
</PropertyGroup>
<Import Project="$(VSToolsPath)\TextTemplating\Microsoft.TextTemplating.targets" Condition="'$(VisualStudioVersion)' == '15.0'" />
我在本地项目上进行了测试,发现无法使用 csproj 文件中的相同语法 "$()"
在命令行中传递属性。
您需要将 BaseResourceFolder 的确切物理路径传递给命令行。从下面的错误。您也错过了 BaseResourceFolder 值末尾的“\”。
'D:\WorkSpace\Projects\Client\Dev\Project\Lw.Domain.Project$(SolutionDir)\packages\LW.Framework$(FrameworkVersion)Lw.System.Metamodel.dll'.
/p:BaseResourceFolder="(phsical path to BaseResourceFolder)\"
希望以上内容对您有所帮助。
我必须 运行 使用 ms 构建的文本转换文件,所以我使用 Transform 作为目标。为了在我的项目中 运行 它,我必须传递一些路径来获取资源 dll。所以我的命令是
D:\WorkSpace\Projects\Client\Dev\Project\Lw.Domain.Project>msbuild /tv:15.0 /t:transform /p:TransformFile="ProjectEntityModelGenerator.tt" /p:SolutionDir=".." /p:FrameworkVersion=4 /p:MetaModelFolder="$(SolutionDir)\packages\LW.Framework$(FrameworkVersion)" /p:BaseResourceFolder="$(SolutionDir)\packages\LW.Framework$(FrameworkVersion)" /p:FrameworkReference="package" /p:IsFromMSBuild="true"
但它没有解析路径,所以我遇到如下问题,
C:\Program Files (x86)\Microsoft Visual Studio17\Professional\MSBuild\Microsoft\VisualStudio\v15.0\TextTemplating\Microsoft.TextTemplating.targets(340,5): error : System.IO.FileNotFoundException: Could not find a part of the path 'D:\WorkSpace\Projects\Client\Dev\Project\Lw.Domain.Project$(SolutionDir)\packages\LW.Framework$(FrameworkVersion)Lw.System.Metamodel.dll'.
[D:\WorkSpace\Projects\Client\Dev\Project\Lw.Domain.Project\Lw.Domain.Project.csproj]
我的 csproj 文件中是否遗漏了什么?下面是我的csproj文件配置,
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
<PropertyGroup>
<!-- Get the Visual Studio version – defaults to 10: -->
<VisualStudioVersion Condition="'$(VisualStudioVersion)' == ''">10.0</VisualStudioVersion>
<!-- Keep the next element all on one line: -->
<VSToolsPath Condition="'$(VSToolsPath)' == ''">$(MSBuildExtensionsPath32)\Microsoft\VisualStudio\v$(VisualStudioVersion)</VSToolsPath>
<SolutionDir>$(SolutionDir)</SolutionDir>
<FrameworkVersion>$(FrameworkVersion)</FrameworkVersion>
<MetaModelFolder>$(SolutionDir)\packages\LW.Framework$(FrameworkVersion)\</MetaModelFolder>
<BaseResourceFolder>$(SolutionDir)\packages\LW.Framework$(FrameworkVersion)\</BaseResourceFolder>
<IsFromMSBuild>$(IsFromMSBuild)</IsFromMSBuild>
<ComputedSolutionDir>$([System.IO.Path]::GetFullPath($([System.IO.Path]::Combine($(ProjectDir),"..\"))))</ComputedSolutionDir>
<DomainResourceFolder>$(SolutionDir)..\Product\Lw.Domain\bin$(Configuration)\</DomainResourceFolder>
</PropertyGroup>
<Import Project="$(VSToolsPath)\TextTemplating\Microsoft.TextTemplating.targets" Condition="'$(VisualStudioVersion)' == '15.0'" />
我在本地项目上进行了测试,发现无法使用 csproj 文件中的相同语法 "$()"
在命令行中传递属性。
您需要将 BaseResourceFolder 的确切物理路径传递给命令行。从下面的错误。您也错过了 BaseResourceFolder 值末尾的“\”。
'D:\WorkSpace\Projects\Client\Dev\Project\Lw.Domain.Project$(SolutionDir)\packages\LW.Framework$(FrameworkVersion)Lw.System.Metamodel.dll'.
/p:BaseResourceFolder="(phsical path to BaseResourceFolder)\"
希望以上内容对您有所帮助。