我一直试图更新ApplicationVersion属性在我的csproj file.witch工作正常;我添加了一个运行自定义任务的目标,以从我的assemblyinfo.cs中提取AssemblyFileVersion;这是毫无疑问的。 但是,当我想使用我更新的ApplicationVersion来确定将我的新构建文件放在哪里时,我得到属性中设置的默认值。csproj MSBuild更新属性
<PropertyGroup>
...
<ApplicationVersion>1.0.0.0</ApplicationVersion>
...
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
<PlatformTarget>AnyCPU</PlatformTarget>
<DebugSymbols>true</DebugSymbols>
<DebugType>full</DebugType>
<Optimize>false</Optimize>
<OutputPath>..\media-converter-BUILD\debug\$(ApplicationVersion)\</OutputPath>
<DefineConstants>DEBUG;TRACE</DefineConstants>
<ErrorReport>prompt</ErrorReport>
<WarningLevel>4</WarningLevel>
<DocumentationFile>..\media-converter-BUILD\debug\$(ApplicationVersion)\MediaConverter.XML</DocumentationFile>
</PropertyGroup>
我的目标
<UsingTask AssemblyFile="GetAssemblyFileVersion.dll" TaskName="GetAssemblyFileVersion.GetAssemblyFileVersion" />
<Target Name="MainAfterCompile">
<CallTarget Targets="AfterCompile" />
<CallTarget Targets="VerifyParam" />
</Target>
<Target Name="AfterCompile">
<GetAssemblyFileVersion strFilePathAssemblyInfo="Properties\AssemblyInfo.cs">
<Output TaskParameter="strAssemblyFileVersion" PropertyName="ApplicationVersionModded" />
</GetAssemblyFileVersion>
<PropertyGroup>
<ApplicationVersion>$(ApplicationVersionModded)</ApplicationVersion>
</PropertyGroup>
</Target>
<Target Name="VerifyParam">
<Message Text="New $(ApplicationVersionModded)" Importance="high"/>
<Message Text="Old Updated $(ApplicationVersion)" Importance="high"/>
</Target>
的GetAssemblyFileVersion.dll我或多或少从一些后我发现在互联网上偷了,就不能再次找到它,这样我就可以”添加一个链接,对不起。
我为什么不起作用的理论是PropertyGroups中的变换和参数在InitailTagets和DefaultTargets都运行之前被渲染。还有的将我的计划行不通
但如果有人知道的一种方式,使其工作,我会感激这里吧
Thanks mate;你只需要用一天的时间就可以为我节省时间。 –