更改.csproj中的构建设置的程序集名称 [英] Change assembly name for build settings in .csproj
问题描述
我有一个要通过命令行与ClickOnce发布的应用程序.我有一个测试版和一个现场版.应该允许它们同时安装,这意味着我需要为其中一个版本更改组装名称(最好还要更改产品名称).我想在构建设置中做到这一点.
I have an application which I want to publish with ClickOnce via command line. I have a test and a live version. It should be allowed to have both installed at the same time, which means that I need to change the assemble name (and preferably also the product name) for one of the builds. I would like to do this in the build settings.
我设法进行了一些构建设置,这些设置可以正常工作,但是我无法找出仅更改其中一个的程序集和产品名称的方法.
I have managed to make some build settings, which works fine, but I cannot figure out how to change the assembly and product name, for just one of them.
我已将以下代码添加到我的.csproj
文件中,该文件使用命令msbuild /target:Test
或msbuild /target:Live
调用. 但是我应该在哪里实施组装和产品名称更改?
I have added the following code to my .csproj
file, which I call with the command msbuild /target:Test
or msbuild /target:Live
. But where do I implement the assembly and product name change?
<PropertyGroup>
<ProjLocation>$(ProjectDir)</ProjLocation>
<ProjLocationReleaseDir>$(ProjLocation)\bin\Debug</ProjLocationReleaseDir>
<ProjPublishLocation>$(ProjLocationReleaseDir)\app.publish</ProjPublishLocation>
<DeploymentFolder>C:\MyProjects\Software\Publish\</DeploymentFolder>
</PropertyGroup>
<!-- Build settings for live version -->
<Target Name="Live" DependsOnTargets="Clean">
<MSBuild Projects="$(ProjLocation)\$(ProjectName).csproj"
Properties="$(DefaultBuildProperties)"
Targets="Publish"/>
<ItemGroup>
<SetupFiles Include="$(ProjPublishLocation)\*.*"/>
<UpdateFiles Include="$(ProjPublishLocation)\Application Files\**\*.*"/>
</ItemGroup>
<Copy SourceFiles="@(SetupFiles)" DestinationFolder="$(DeploymentFolder)\Live\" />
<Copy SourceFiles="@(UpdateFiles)" DestinationFolder="$(DeploymentFolder)\Live\Application Files\%(RecursiveDir)"/>
</Target>
<!-- Build settings for test version -->
<Target Name="Test" DependsOnTargets="Clean">
<MSBuild Projects="$(ProjLocation)\$(ProjectName).csproj"
Properties="$(DefaultBuildProperties)"
Targets="Publish"/>
<ItemGroup>
<SetupFiles Include="$(ProjPublishLocation)\*.*"/>
<UpdateFiles Include="$(ProjPublishLocation)\Application Files\**\*.*"/>
</ItemGroup>
<Copy SourceFiles="@(SetupFiles)" DestinationFolder="$(DeploymentFolder)\Public Test\" />
<Copy SourceFiles="@(UpdateFiles)" DestinationFolder="$(DeploymentFolder)\Public Test\Application Files\%(RecursiveDir)"/>
</Target>
推荐答案
您可以将"AssemblyName"属性添加到PropertyGroup.像这样:
You can add "AssemblyName" property to the PropertyGroup. like this:
<PropertyGroup>
<AssemblyName>YourAppName</AssemblyName>
</PropertyGroup>
或者您可以使用MSBuild命令行开关.像这样:
or you can use the MSBuild command line switch. like this :
msbuild /property:AssemblyName=YourAppName
这篇关于更改.csproj中的构建设置的程序集名称的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!