lazyload the images

最新精選 Featured post

漫畫 - 異世界 清單

訂閱


每月雙數周日為固定發佈日

本站內任何媒體的內容,包括但不限於 影片/聲音檔/文章/圖片,純屬資訊分享和教學用途, 本站內容只作為一般用途,它並沒有考慮您的個人需要、投資目標及特定財政狀況。 本站內容並非投資意見,亦不構成任何投資產品之要約、招攬或建議購買或出售任何存款或投資任何下述投資產品。

投資者須注意,所有投資涉及風險(包括可能會損失投資本金),投資產品的價格可升或可跌, 而所呈列的過往表現資料並不表示將來亦會有類似的表現。

投資者在作出任何投資決定前,投資者應進行所須或適當的獨立調查,包括評估所涉及的投資風險。

25/07/2026

ClickOnce maintain and deploy to DEV, UAT, PRO

文章分類:

 



事緣

一般來說program 不論 server / client 都分成DEV / UAT / PROD 三個 environment

.net Core 之前通常都放在 web.config / app.config

在更早之前很多都沒有固定位置,各自發揮

然後Git來了

假如用 branch 分開 不同的config,海豚不太喜歡

即是只有app.config

branch-DEV, branch-UAT, branch-PROD 的value都不同

日後 dev 加減改value,很容易出現 conflit

然後海豚最近接手一套project的source code

問題一

然後build and debug UAT 時一直報錯

因為 AssemblyName 在UAT時改了名稱


問題二


然後build and debug DEV 時一直報
config 有attribute duplicated





Soluation 解決方案

海豚最後明白了為什麼上手要

特別為UAT 改了 AssemblyName

猜測是deploy ClickOnce 時

想同時deploy PROD 、 UAT 

那就需要改名稱,不然同名不能重複安裝 一個UAT,一個PROD 在同一電腦上

winForm.csproj

  <PropertyGroup>

    <Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>

    <Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>

    <ProjectGuid>XXX</ProjectGuid>

    <OutputType>WinExe</OutputType>

    <AppDesignerFolder>Properties</AppDesignerFolder>

    <RootNamespace>Reminder.WinForm</RootNamespace>

    <AssemblyName>Reminder.WinForm</AssemblyName>


  <PropertyGroup Condition="'$(Configuration)|$(Platform)' == 'UAT|AnyCPU'">

    ...

    <ProductName>UAT.XRayReminder</ProductName>

    <AssemblyName>Reminder.WinForm.UAT</AssemblyName>

  </PropertyGroup>


海豚找到 以下應該可行

<StartAction>Program</StartAction>

<StartProgram>C:\Path\To\Your\External\EnterpriseApp.exe</StartProgram>

<StartArguments>/debugMode</StartArguments>

<StartWorkingDirectory>C:\Path\To\Your\External\</StartWorkingDirectory>



另外

海豚看bin / obj 內build 完的config 真的有attribute / element duplicated

只要將 Insert 改成 Replace / Update



Reference

Google AI

search

VS xdt:Locator="Match(name)"


Answer

xdt:Locator="Match(name)" is an XML Document Transform (XDT) directive used in Visual Studio to locate and manipulate specific elements within XML files (like web.config or app.config) during project builds or deployments. It instructs the transformation engine to find an element in the target file whose name attribute exactly matches the name attribute in your transform file.


Code Example

<configuration xmlns:xdt="http://schemas.microsoft.com/XML-Document-Transform">

  <connectionStrings>

    <add name="MyDB" 

         connectionString="Data Source=ReleaseSQLServer;Initial Catalog=MyReleaseDB;Integrated Security=True" 

         xdt:Transform="SetAttributes" 

         xdt:Locator="Match(name)" />

  </connectionStrings>

</configuration>




https://learn.microsoft.com/en-us/previous-versions/aspnet/dd465326(v=vs.110)


https://www.youtube.com/watch?v=IpJOREDFTnY


https://jengting.blogspot.com/2020/10/VS-Configuration-Transform-AppConfig.html


Answer

When you pair this locator with a transformation attribute (such as xdt:Transform="SetAttributes" or xdt:Transform="Replace"), it modifies only the matched node. If multiple attributes are required for a precise match, they can be combined in a comma-delimited list (e.g., xdt:Locator="Match(name, providerName)").


https://www.zoeydc.com/Post/visual-studio-release-project-webconfig



Google AI

search

VS debug StartAction multiple


No comments:

Post a Comment