0

the relative content in msbuild.proj file:

<Message Text="*****check the site exists*****" Importance="high"/>
<Exec Command="C:\WINDOWS\System32\inetsrv\appcmd.exe list site /name:$(WebAppSiteName) " ContinueOnError="true">
  <Output TaskParameter="ExitCode" PropertyName="ErrorCode2" />
</Exec>

<Message Text="*****if not exists create site*****" Importance="high"  Condition="'$(ErrorCode2)' > '0'" />
<Exec Command="C:\WINDOWS\System32\inetsrv\appcmd.exe add site /name:$(WebAppSiteName) /bindings:http/*:80:$(SiteDomain) /applicationDefaults.applicationPool:$(WebAppSiteName) /physicalPath:$(BuildSolutionDir)$(DeployDir)Website" Condition="$(WebAppSiteName)!=''  and '$(ErrorCode2)' > '0'"></Exec>

in above: the actual parameter(/physicalPath) value of runtime is : D:\YDJWebsite.Dev\deply\fw\..\..\mkltest2Website

actually, the path of above is equivalent to D:\YDJWebsite.Dev\mkltest2Website

when accessing the site, the error shows: 500 - internal server error, resource not found

if i change the path to right format "D:\YDJWebsite.Dev\mkltest2Website", the error disappeared

the physical path of website in iis shows here.

now, i know the only solution is to convert the paramter value(/physicalPath) to right format?

but how to do it in proj file? is there any suggestion ? tks.

linus
  • 3
  • 4

1 Answers1

0

i have solved the problem with the msbuild's inline task.

<UsingTask TaskName="AbsolutePath" TaskFactory="CodeTaskFactory" AssemblyFile="$(MSBuildToolsPath)\Microsoft.Build.Tasks.Core.dll">
  <ParameterGroup>
      <Path ParameterType="System.String" Required="true" />
      <FullPath ParameterType="System.String" Output="true" />  
  </ParameterGroup>
  <Task>
      <Reference Include="System.Core" />
      <Using Namespace="System" />
      <Using Namespace="System.IO" />
      <Using Namespace="System.Text.RegularExpressions" />
      <Using Namespace="Microsoft.Build.Framework" />
      <Using Namespace="Microsoft.Build.Utilities" />
      <Code Type="Fragment" Language="cs">
          <![CDATA[
          try {
                if(string.IsNullOrWhiteSpace(Path))
                {
                    FullPath = "";
                }
                else
                {
                    DirectoryInfo dirInfo = new DirectoryInfo(Path);
                    FullPath = dirInfo.FullName;
                }
          }
          catch (Exception ex) {
            FullPath = "";
          }
      ]]>
      </Code>
  </Task>

<AbsolutePath Path="$(BuildSolutionDir)$(DeployDir)Website">
        <Output TaskParameter="FullPath" PropertyName="FullPath" />
    </AbsolutePath>
<Message Text="$(FullPath)"/>

tks.

linus
  • 3
  • 4