7

मैं Azure कंप्यूट एम्यूलेटर ठीक से पुन: प्रारंभ नहीं के साथ कुछ समस्याएं हैं। इसे हल करने के लिए मैं csrun /devfabric:stop को विजुअल स्टूडियो समाधान में प्री-बिल्ड चरण में जोड़ना चाहता हूं।मैं कैसे Azure एसडीके csrun.exe सुविधा के लिए पथ अनुमान करते हैं?

समस्या यह है कि csrun.exe C:\Program Files\Windows Azure SDK\v1.4\bin में मेरी मशीन पर स्थित है और यह पथ %PATH% निर्देशिका सूची पर नहीं है। मैं अपने समाधान में उस पथ को हार्डकोड नहीं करना चाहता हूं।

वहाँ किसी तरह कुछ वातावरण चर या कुछ इसी तरह का उपयोग कर की तरह पथ निकालना है?

+0

अफसोस की बात है, मुझे ऐसा कोई रास्ता नहीं मिला है ... –

उत्तर

6

आप संस्करण द्वारा रजिस्ट्री से Azure एसडीके पथ पढ़ सकते हैं। पथ का अंतिम भाग संस्करण है ... आपका कोड या तो किसी संस्करण पर सेट किया जा सकता है या आप नवीनतम खोज करने वाले वी कुंजी पर फिर से सक्रिय कर सकते हैं। मैं आपके द्वारा समर्थित संस्करण के लिए निरंतर होने की अनुशंसा करता हूं और जब आप प्री-रिक के रूप में एक नया एसडीके लेते हैं।

HKEY_LOCAL_MACHINE \ SOFTWARE \ Microsoft \ माइक्रोसॉफ्ट SDKs \ ServiceHosting \ v1.4

वहाँ एक "InstallPath" उन रास्तों के तहत कुंजी है।

0

मैं इस एक ही समस्या थी और मैं एक PowerShell स्क्रिप्ट एसडीके बिन फ़ोल्डर के लिए पथ के साथ एक वातावरण चर सेट का उत्पादन किया। यह स्वचालित रूप से रजिस्ट्री को खोजेगा और नवीनतम स्थापित संस्करण ढूंढ जाएगा। यह आपकी रजिस्ट्री 32 बिट या 64 बिट मोड में चलती है या नहीं, यह वैकल्पिक रजिस्ट्री स्थान पर फ़ॉलबैक है। आशा करता हूँ की ये काम करेगा!

अस्वीकरण: मैं इसे यहाँ पोस्ट करने से पहले स्क्रिप्ट से कुछ सामान निकाल दिया है और मैं इसे बाद में परीक्षण नहीं किया था, लेकिन मुझे लगता है कि यह डिबग करने के लिए मुश्किल नहीं है/अपनी आवश्यकताओं के इसे समायोजित।

#the script attempts to perform the following: 
#1. look for the HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Microsoft SDKs\ServiceHosting" registry key 
#2. if the above key is present then read the child keys and retrieve the largest version number 
#3. from the largest version number key retrieve the "InstallPath" string value to determine the path of the latest Azure SDK installation 
#4. add an environment variable called "AzureSDKBin" (if not already added) with the path to the "bin" folder of the latest Azure SDK installation 

#define the name of the config variable 
$azureSDKPathVariable = 'AzureSDKBin' 
$azureRegistryKey = 'HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Microsoft SDKs\ServiceHosting' 
$azureAlternateRegistryKey = 'HKEY_LOCAL_MACHINE\SOFTWARE\Wow6432Node\Microsoft\Microsoft SDKs\ServiceHosting' #this is in case the PowerShell runs in 32bit mode on a 64bit machine 
$azureMatchedKey = '' 

#check if the environment variable was already defined 
if ([environment]::GetEnvironmentVariable($azureSDKPathVariable,"User").Length -eq 0) { 
    'Variable ' + $azureSDKPathVariable + ' is not defined, proceeding...' 

    #try reading the registry key 
    $keyExists = Get-Item -Path Registry::$azureRegistryKey -ErrorAction SilentlyContinue 

    $azureMatchedKey = $azureRegistryKey #make a note that we found this registry key 

    #stop if the key does not exist 
    if ($keyExists.Length -eq 0) { 
     'Could not find registry key in primary location: ' + $azureRegistryKey + ', attempting search in alternate location: ' + $azureAlternateRegistryKey 

     #search the alternate location 
     $keyExists = Get-Item -Path Registry::$azureAlternateRegistryKey -ErrorAction SilentlyContinue 

     $azureMatchedKey = $azureAlternateRegistryKey #make a note that we found this registry key 

     if ($keyExists.Length -eq 0) { 
      'Could not find registry key for determining Azure SDK installation: ' + $azureAlternateRegistryKey 
      'Script failed...' 
      exit 1 
     } 
    } 

    'Found Azure SDK registry key: ' + $azureMatchedKey 

    #logic for determining the install path of the latest Azure installation 
    #1. get all child keys of the matched key 
    #2. filter only keys that start with "v" (e.g. "v2.2", "v2.3") 
    #3. sort the results by the "PSChildName" property from which we removed the starting "v" (i.e. only the version number), descending so we get the latest on the first position 
    #4. only keep the first object 
    #5. read the value named "InstallPath" under this object 
    $installPath = (Get-ChildItem -Path Registry::$azureMatchedKey | Where-Object { $_.PSChildName.StartsWith("v") } | sort @{expression={ $_.PSChildName.TrimStart("v") }} -descending | Select-Object -first 1| Get-ItemProperty -name InstallPath).InstallPath 

    'Detected this Azure SDK installation path: "' + $installPath + '"' 

    #set the variable with the "bin" folder 
    [Environment]::SetEnvironmentVariable($azureSDKPathVariable, $installPath + 'bin\', "User") 

    'Assigned the value "' + [environment]::GetEnvironmentVariable($azureSDKPathVariable,"User") + '" to environment variable "' + $azureSDKPathVariable + '"' 
} 
else { 
    'Environment variable "' + $azureSDKPathVariable + '" is already defined and has a value of "' + [environment]::GetEnvironmentVariable($azureSDKPathVariable,"User") + '"' 
} 
संबंधित मुद्दे