C # API를 통해 Foundation 2010에서 해결책을 배포하는 올바른 방법은 무엇입니까?
-
09-12-2019 - |
문제
저는 SharePoint Foundation 2010의 "포털"을 개발하는 팀에 있습니다. 저는 SharePoint의 새 인스턴스를 설정하는 설치 프로그램을 만들어야합니다. 솔루션 파일과 SharePoint의 구성 만 설치하는 것만으로 처리합니다. 설치 프로그램은 GAC에 파일을 배포하고 페더레이션 보안 클라이언트 (SharePoint 클레임 기반 인증에 사용됨)를 만듭니다.
인스턴스 설치 중에는 SharePoint와 관련이있는 몇 가지 작업을 완료하고 .NET 3.5에서 SharePoint API를 사용하는 몇 가지 작업을 완료합니다.
- 트러스트 생성 / 구성
- 웹 응용 프로그램을 만듭니다.
- 팜 및 웹 응용 프로그램에 솔루션 배포
- 기본 사이트 모음 만들기
- 사이트 모음에서 기본 기능을 활성화
- 웹 응용 프로그램 "속성" 업데이트
단일 SharePoint 서버에 설치 작업을 제대로 작동시킬 수있었습니다. 즉, 하나의 서버는 팜 데이터베이스를 호스팅하고 다른 서버는 SharePoint Services의 전체 스택입니다. 호스팅 환경에서 SharePoint의 실제 설정을 모방하는 설정으로 테스트를 시작했습니다. 거기에는 데이터베이스 서버가 있고 최소한 3 개의 SharePoint 서버가 있으며 중 하나만 중앙 관리가 있습니다.
실행중인 문제는이 경우에 오류가 올바르게 적을 수 있고 기능의 활성화를 제외하고 위의 모든 단계를 수행 할 수 있습니다. 이 단계를 수행하는 코드를 제거하고 "특성"을 제외한 "속성"을 제외한 "속성"을 제외한 웹 응용 프로그램, 사이트 모음, 신뢰 등)이 기본값 "팀"테마를 보는 것으로 확인되었습니다. ...에 그러나 API를 통해 또는 사이트 모음 설정을 통해 기본 기능을 활성화하면 더 이상 사이트에 액세스하고 오류가 발생할 수 없습니다.
이것은 내 문제의 핵심과 여기에서 설명 할 때 직면하는 문제에 온다. 우리의 솔루션은 SharePoint 외부의 다른 서비스에 대한 보안 측면 및 의존의 측면에서 많은 구성을 포함하는 것이 매우 복잡합니다. 우리 설정 중 일부가 서버를 통해 전파되지 않으면 해결책에서 내부 오류가 발생하여 오류 페이지를 유발할 수 있습니다. 또한 농장 상황에 꽂혀 있다면 "속성"을 설정할 때도 알지 못합니다. 나는이 일을 처음 시작했을 때 내가이 일을 처음 시작했을 때 이것이 지금 보이는 것과 비슷한 문제를 일으켰습니다.
나는 또한 솔루션이 올바르게 배포되고 있으므로 특징이 손상되었는지 확실하지 않습니다. 각 SharePoint 서버에서 ULS 뷰어를 설정하면 오류 페이지에서 오류에 대한 오류에 대한 상관 ID와 관련된 항목을 찾을 수 없습니다. 실제로 "Master"SharePoint Server에 ULS Viewer에 이벤트가 없습니다. 다른 두 서버의 뷰어에서 솔루션 배포 및 수축을 볼 수 있습니다.
여러 서버가있는 팜에서 발생하는 일이 없어야합니다. 나는 누군가가 솔루션을 배포하고 속성을 설정하는 데 사용하는 코드의 비트를 살펴볼 수 있기를 바랍니다. 나는 또한 내가 왜 내가 ULS 시청자들 중 어느 것에 도착하는 오류를 볼 수 없는지 알아 내고 싶다. 누군가 나를 위해 이것을 설명 할 수 있습니까?
또한 C # API를 통해 SharePoint를 구성하고 설정하는 방법에 대한보다 확실한 예를 누릴 수 있습니다. 이 시점까지 나는 Commandlet의 코드를 만들고 코드에서 할 수있는 것을 복제하고 있습니다. C #을 통해 기능을 활성화하고 기능을 활성화하기 위해 Stsadm.exe를 실행하는 프로세스를 만드는 "올바른"방법이 아직 없습니다.
여기에 솔루션을 추가하고 배포하는 코드가 있습니다.
.SPSolution newSolution = SPFarm.Local.Solutions.Add(Path.Combine(this.SharePointPointRootFolder, solutionDefinition.filename)); if (!solutionDefinition.webApplicationSpecific) { Console.WriteLine("Adding a farm specific solution."); newSolution.Deploy(DateTime.Now, true, true); this.WaitForSolutionJobsToComplete(newSolution.Id); newSolution.Synchronize(); } else //specific to a web application. Load the new solution. { Console.WriteLine("Adding web application specific solution."); Collection<SPWebApplication> webAppCol = new Collection<SPWebApplication>(); webAppCol.Add(this.WebApplication); newSolution.Deploy(DateTime.Now, true, webAppCol, true); this.WaitForSolutionJobsToComplete(newSolution.Id); newSolution = SPFarm.Local.GetObject(newSolution.Id) as SPSolution; newSolution.Synchronize(); this.WaitForSolutionJobsToComplete(newSolution.Id); newSolution.Update(); }
여기에 기능을 활성화하기위한 코드가 있습니다. stsadm.exe를 사용하는 프로세스를 사용합니다 :
.void UpdateFeatures(SPSite site) { Console.WriteLine("Updating features."); SPSolutionDefinitionCollection collection = SolutionConfigurer.LoadSolutionDefinitions(); foreach (SPSolutionDefinition solutionDefinition in collection.spSolutionDefinition) { Guid id = new Guid(solutionDefinition.ID); if (solutionDefinition.spFeatureDefinition != null && solutionDefinition.spFeatureDefinition.Length > 0) { foreach (Models.SPFeatureDefinition fDef in solutionDefinition.spFeatureDefinition) { Guid fDefId = new Guid(fDef.ID); //this.Activate(fDefId, site); Process stsadmP = WebApplicationConfigurer.GetSTSADMProcess(this.STSADMPath, "-o activatefeature -id " + fDef.ID + " -url " + this.SiteCollectionUrl + " -force"); Console.WriteLine(string.Format("Invoking STSADM.EXE for feature deployment: {0} with arguments:{1}", stsadmP.StartInfo.FileName, stsadmP.StartInfo.Arguments)); stsadmP.Start(); stsadmP.WaitForExit(); if (stsadmP.ExitCode == 0) { Console.WriteLine(string.Format("STSADM.EXE successfully ran for feature id {0} and produced this output: {1}", fDefId, stsadmP.StandardOutput.ReadToEnd())); } else { Console.WriteLine(string.Format("STSADM.EXE did not produce a successful exit code for feature id {0} and produced this output: {1} + {2}", fDefId, stsadmP.StandardOutput.ReadToEnd(), stsadmP.StandardError.ReadToEnd())); } } } } }
여기에 내가 재산을 업데이트하는 방법입니다. 나는 솔루션을 배포 한 후에도이 작업을 수행했기 때문에이 작업을 수행하지만 기능을 활성화하는 것이 값을 재설정하는 것 같습니다.
.public void UpdatePropertiesWebApplication() { string dnsName = this.SigningCertificate.GetNameInfo(X509NameType.DnsName, false); SPWebApplication webApplication = SPFarm.Local.GetObject(this.WebApplicationId) as SPWebApplication; if (webApplication != null) { Console.WriteLine("Updating property information for the web application."); if (!webApplication.Properties.ContainsKey(Constants.PropertyBagKeys.ESB_ROOT)) { webApplication.Properties.Add(Constants.PropertyBagKeys.ESB_ROOT, this.ESBUrl); } else { Console.WriteLine("Updating ESB Root URL. " + this.ESBUrl); webApplication.Properties[Constants.PropertyBagKeys.ESB_ROOT] = this.ESBUrl; } Console.WriteLine("ESB Root Url: " + webApplication.Properties[Constants.PropertyBagKeys.ESB_ROOT]); if (!webApplication.Properties.ContainsKey(Constants.PropertyBagKeys.REALM)) { webApplication.Properties.Add(Constants.PropertyBagKeys.REALM, this.SharePointTrustPoint); } else { Console.WriteLine("Updating realm. " + this.SharePointTrustPoint); webApplication.Properties[Constants.PropertyBagKeys.REALM] = this.SharePointTrustPoint; } Console.WriteLine("Realm: " + webApplication.Properties[Constants.PropertyBagKeys.REALM]); if (!webApplication.Properties.ContainsKey(Constants.PropertyBagKeys.SSO_ROOT)) { webApplication.Properties.Add(Constants.PropertyBagKeys.SSO_ROOT, this.SSOUrl); } else { Console.WriteLine("Updating the broker url. " + this.SSOUrl); webApplication.Properties[Constants.PropertyBagKeys.SSO_ROOT] = this.SSOUrl; } Console.WriteLine("Broker Url: " + webApplication.Properties[Constants.PropertyBagKeys.SSO_ROOT]); if (!webApplication.Properties.ContainsKey(Constants.PropertyBagKeys.TRUSTED_CERT_DNS_IDENT)) { webApplication.Properties.Add(Constants.PropertyBagKeys.TRUSTED_CERT_DNS_IDENT, dnsName); } else { Console.WriteLine("Updating trusted cert dns identity. " + dnsName); webApplication.Properties[Constants.PropertyBagKeys.TRUSTED_CERT_DNS_IDENT] = dnsName; } Console.WriteLine("Trusted Certificate Identity: " + webApplication.Properties[Constants.PropertyBagKeys.TRUSTED_CERT_DNS_IDENT]); webApplication.Update(true); } }
해결책
일반적인 질문에 답변을 위해 SharePoint 2010에서 솔루션을 배포하는 권장 방식은 PowerShell을 사용하는 것입니다. 새로운 기능 : Windows PowerShell for SharePoint :
Windows PowerShell은 stsadm.exe 관리 도구를 대체합니다. 앞으로, Windows PowerShell 스크립팅 기술을 사용하여 SharePoint Foundation 2010에서 새로운 명령 줄 스크립트를 개발해야합니다.
여기에 PowerShell을 배포하기위한 몇 가지 샘플 및 스크립트가 있습니다.
- SharePoint 2010 솔루션 패키지 배포 방법 Windows PowerShell 사용 를 사용합니다
- 배포 PowerShell SharePoint 2010 솔루션 패키지
- . PowerShell을 사용하여 SharePoint 2010 솔루션 배포
- SharePoint 2010에서 PowerShell이있는 솔루션 추가 및 배포
및 여기서 PowerShell의 기능 활성화에 대한 정보는 다음과 같습니다.
- 기능 설치 또는 제거
- SharePoint 2010에서 PowerShell에서 기능 활성화 및 비활성화
특정 질문에 답변하면 C # : 의 기능을 활성화 할 수 있습니다.
.Guid fDefId = new Guid(fDef.ID); site.Features.Add(fDefId);
자세한 정보는 Spsite.Features 및 spfeatureCollection.add .
다른 팁
완전히 솔직히 나는 stsadm을 직접 할 수있는 코드에서 어떤 것도 할 수있는 방법을 더 이상 볼 수 없습니다.
그래서 항상 내가 필요한 것과 동일한 것을 사용합니다 :
stsadm -o deletesolution -name solution.wsp -override
stsadm -o addsolution -filename c:\path\solution.wsp
stsadm -o deploysolution -name solution.wsp -allowgacdeployment -local -force
.
다음 ...
특징을 활성화하십시오
설치 솔루션 옵션
마스터 템플릿을 적용하십시오
하위 사이트 만들기
목록 만들기
웹 파트 추가
사용 권한 설정
탐색 / 표시 탐색 / 표시
배포에 필요한 모든 데이터를 추가하십시오
마침
사용하는 방법을 사용하여 솔루션을 배포하려는 데 많은 문제가있었습니다 (여기에 게시 한 검색 및 솔루션 없음)