0

Ist es möglich, eine Einstellung oder eine Variable zu ändern, wenn die Anwendung veröffentlicht istVisual Studio 2015 - Einstellung ändern oder Variable zum Zeitpunkt der Veröffentlichung

oder gibt es irgendeine Art von Bedingung eines IF-THEN gegen laufen?

zum Beispiel mag ich die Log-Dateien, die Art und Weise ändern, geschrieben werden, wenn ich veröffentliche, und ich vergesse oft die Änderung zu machen, wenn ich es veröffentlichen

+0

Haben Sie sich in Profilen veröffentlichen? –

+0

Ich habe einige über sie gelesen, wenn das tut, werde ich tiefer graben – mreinsmith

+0

Sie sind sehr gut für mehrere Release-Umgebungen. Ich gebe Ihnen einen Ausschnitt davon, wie wir Publizierungsprofile verwenden, um Variablen in einer Antwort unter –

Antwort

1

Web.Live.Config:

<configuration xmlns:xdt="http://schemas.microsoft.com/XML-Document-Transform"> 
    <!-- 
    In the example below, the "SetAttributes" transform will change the value of 
    "connectionString" to use "ReleaseSQLServer" only when the "Match" locator 
    finds an attribute "name" that has a value of "MyDB". 
--> 
    <appSettings> 
    <add key="ClaimPackPath" value="C:\\inetpub\\wwwroot\\Application\\ClaimPacks\\" xdt:Locator="Match(key)" xdt:Transform="Replace" /> 
</appSettings> 
</configuration> 

Wg.Debug.Config:

<configuration xmlns:xdt="http://schemas.microsoft.com/XML-Document-Transform"> 
    <!-- 
    In the example below, the "SetAttributes" transform will change the value of 
    "connectionString" to use "ReleaseSQLServer" only when the "Match" locator 
    finds an attribute "name" that has a value of "MyDB". 
--> 
    <appSettings> 
    <add key="ClaimPackPath" value="C:\\Debug\\wwwroot\\Application\\ClaimPacks\\" xdt:Locator="Match(key)" xdt:Transform="Replace" /> 
</appSettings> 
</configuration> 

dann in der Anwendung können Sie die Variable anfordern, wie so:

string filepath = ConfigurationManager.AppSettings["ClaimPackPath"]; 

Und es wird für was auch immer Sie bei der Auswahl publish ändern Profil veröffentlichen :)