Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Publish Configuration disabled for csproj

Why can't I change these settings shown in the image below? CSProj Properties windows showing disabled configuration profile

This is a clickOnce application, and my problem is that I want to change by publish path, assembly name, product name, install URL, and preform some app.config translations based on the build configuration. I am able to achieve this by manually editing the csproj like so

<PropertyGroup Condition=" '$(Configuration)' == 'Debug' ">
    <AssemblyName>someApplicationTest</AssemblyName>
    <ProductName>Some Application Test</ProductName>
    <PublishUrl>c:\publish\someApplicationTest\</PublishUrl>
    <InstallUrl>http://sub.example.com/someApplicationTest/</InstallUrl>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)' == 'Release' ">
    <AssemblyName>someApplication</AssemblyName>
    <ProductName>Some Application</ProductName>
    <PublishUrl>c:\publish\someApplication\</PublishUrl>
    <InstallUrl>http://sub.example.com/someApplication/</InstallUrl>
</PropertyGroup>

I'm just confused why these options are disabled in visual studio and if I'm missing something. Perhaps I'm confused and these controls weren't even intended for this purpose.

Also, I'm going to be investigating Squirrel.Windows as an alternative later, but for now I wanted to learn more about this.

like image 864
Oxymoron Avatar asked Oct 30 '22 15:10

Oxymoron


1 Answers

This is just a visual representation of the structure of a project file. Some settings can have different values for different configurations. Others have only one value that doesn't depend on the configuration. The best example of the first set are the settings in the Build tab. Of course you want to build your program differently in the Release build. So the configuration combos are enabled.

Also have a look-see in the .csproj file with a text editor, Notepad will do just fine. Note the <PropertyGroup> elements, some have a Condition attribute that enables them for a specific configuration. The publish properties are located in the PropertyGroup without a Condition.

So for the settings in the Publish tab Microsoft decided that it was not necessary to make the settings specific to a configuration. Which makes sense if you think about it, you'd only publish your Release build. Well, normally. So the combos are disabled. Feature, not a bug.

like image 110
2 revs Avatar answered Nov 08 '22 03:11

2 revs