在Mac上构建项目失败

时间:2018-06-25 06:20:42

标签: asp.net-mvc macos asp.net-mvc-5 msbuild visual-studio-mac

某些背景优先:

在我的研发团队中,我们有一些用.NET MVC 5编写的Web项目。我们还有一些项目正在python(带有pycharm)的开发机器上运行。

基本上,我们使用Mac进行开发,但是由于生产服务器在Windows上构建项目,因此我们还使用运行Windows 10的VM(使用并行程序)进行工作。

因此,当我进行开发(我是网络开发人员。主要是客户端,但有时还会做一些服务器)时,我正在运行2个pyhton项目,本地数据库,本地弹性搜索以及带有Visual Studio 2017的Windows 10 VM MVC和用于客户开发的Webstorm。

这对我来说远非理想,因为我有一台好的机器应该可以提供出色的性能,但是实际上它并没有那么快地工作。

所以我尝试使用Mac的Rider和Mac的Visual Studio构建我们的解决方案,但是如果失败并出现相同的错误:

"/Users/dvir/projects/S6/web-dashboard/packages/RazorGenerator.MsBuild.2.2.6/build/RazorGenerator.MsBuild.targets(9,9): Error: InvalidCastException: Specified cast is not valid."

完整错误堆栈为:

"/Users/dvir/projects/Shift6/web-dashboard/packages/RazorGenerator.MsBuild.2.2.6/build/RazorGenerator.MsBuild.targets(9,9): Error: InvalidCastException: Specified cast is not valid.
  at System.Web.Configuration.WebConfigurationHost.MapPathFromMapper (System.String virtualPath) [0x0001b] in /Users/builder/jenkins/workspace/build-package-osx-mono/2018-02/external/bockbuild/builds/mono-x64/mcs/class/System.Web/System.Web.Configuration_2.0/WebConfigurationHost.cs:275 
  at System.Web.Configuration.WebConfigurationHost.MapPath (System.String virtualPath) [0x00024] in /Users/builder/jenkins/workspace/build-package-osx-mono/2018-02/external/bockbuild/builds/mono-x64/mcs/class/System.Web/System.Web.Configuration_2.0/WebConfigurationHost.cs:232 
  at System.Web.Configuration.WebConfigurationHost.GetStreamName (System.String configPath) [0x00061] in /Users/builder/jenkins/workspace/build-package-osx-mono/2018-02/external/bockbuild/builds/mono-x64/mcs/class/System.Web/System.Web.Configuration_2.0/WebConfigurationHost.cs:148 
  at System.Configuration.Configuration.Init (System.Configuration.Internal.IConfigSystem system, System.String configPath, System.Configuration.Configuration parent) [0x0000e] in /Users/builder/jenkins/workspace/build-package-osx-mono/2018-02/external/bockbuild/builds/mono-x64/mcs/class/System.Configuration/System.Configuration/Configuration.cs:127 
  at System.Configuration.Configuration..ctor (System.Configuration.InternalConfigurationSystem system, System.String locationSubPath) [0x00056] in /Users/builder/jenkins/workspace/build-package-osx-mono/2018-02/external/bockbuild/builds/mono-x64/mcs/class/System.Configuration/System.Configuration/Configuration.cs:96 
  at System.Configuration.Configuration..ctor (System.Configuration.InternalConfigurationSystem system, System.String locationSubPath) [0x00038] in /Users/builder/jenkins/workspace/build-package-osx-mono/2018-02/external/bockbuild/builds/mono-x64/mcs/class/System.Configuration/System.Configuration/Configuration.cs:91 
  at System.Configuration.Configuration..ctor (System.Configuration.InternalConfigurationSystem system, System.String locationSubPath) [0x00038] in /Users/builder/jenkins/workspace/build-package-osx-mono/2018-02/external/bockbuild/builds/mono-x64/mcs/class/System.Configuration/System.Configuration/Configuration.cs:91 
  at System.Configuration.Configuration..ctor (System.Configuration.InternalConfigurationSystem system, System.String locationSubPath) [0x00038] in /Users/builder/jenkins/workspace/build-package-osx-mono/2018-02/external/bockbuild/builds/mono-x64/mcs/class/System.Configuration/System.Configuration/Configuration.cs:91 
  at System.Configuration.Configuration..ctor (System.Configuration.InternalConfigurationSystem system, System.String locationSubPath) [0x00038] in /Users/builder/jenkins/workspace/build-package-osx-mono/2018-02/external/bockbuild/builds/mono-x64/mcs/class/System.Configuration/System.Configuration/Configuration.cs:91 
  at System.Configuration.InternalConfigurationFactory.Create (System.Type typeConfigHost, System.Object[] hostInitConfigurationParams) [0x0000d] in /Users/builder/jenkins/workspace/build-package-osx-mono/2018-02/external/bockbuild/builds/mono-x64/mcs/class/System.Configuration/System.Configuration/InternalConfigurationFactory.cs:41 
  at System.Web.Configuration.WebConfigurationManager.OpenMappedWebConfiguration (System.Web.Configuration.WebConfigurationFileMap fileMap, System.String path) [0x00000] in /Users/builder/jenkins/workspace/build-package-osx-mono/2018-02/external/bockbuild/builds/mono-x64/mcs/class/System.Web/System.Web.Configuration_2.0/WebConfigurationManager.cs:275 
  at RazorGenerator.Core.MvcWebConfigTransformer.Initialize (RazorGenerator.Core.RazorHost razorHost, System.Collections.Generic.IDictionary`2[TKey,TValue] directives) [0x000a2] in <743fc9a5bb9c4653a158bfeee3353916>:0 
  at RazorGenerator.Core.AggregateCodeTransformer.Initialize (RazorGenerator.Core.RazorHost razorHost, System.Collections.Generic.IDictionary`2[TKey,TValue] directives) [0x00015] in <743fc9a5bb9c4653a158bfeee3353916>:0 
  at RazorGenerator.Core.MvcViewTransformer.Initialize (RazorGenerator.Core.RazorHost razorHost, System.Collections.Generic.IDictionary`2[TKey,TValue] directives) [0x00000] in <743fc9a5bb9c4653a158bfeee3353916>:0 
  at RazorGenerator.Core.RazorCodeTransformerBase.RazorGenerator.Core.IRazorCodeTransformer.Initialize (RazorGenerator.Core.IRazorHost razorHost, System.Collections.Generic.IDictionary`2[TKey,TValue] directives) [0x00000] in <743fc9a5bb9c4653a158bfeee3353916>:0 
  at RazorGenerator.Core.RazorHost.GenerateCode () [0x00000] in <743fc9a5bb9c4653a158bfeee3353916>:0 
  at RazorGenerator.MsBuild.RazorCodeGen.ExecuteCore () [0x00166] in <0ed6243610554ecd93f4e898274cb949>:0 
 (Shift6.Dashboard)

错误指向以下文件的第21行: (以RazorCodeGen标签开头的标签)

<Project xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
    <PropertyGroup>
        <RazorGeneratorMsBuildPath Condition=" '$(RazorGeneratorMsBuildPath)' == '' ">$(MSBuildThisFileDirectory)\..\tools\RazorGenerator.MsBuild.dll</RazorGeneratorMsBuildPath>
        <RazorViewsCodeGenDirectory Condition=" '$(RazorViewsCodeGenDirectory)' == '' ">$(MsBuildProjectDirectory)\obj\CodeGen\</RazorViewsCodeGenDirectory>

        <CompileDependsOn>
            PrecompileRazorFiles;
            $(CompileDependsOn);
        </CompileDependsOn>
    </PropertyGroup>

    <ItemGroup>
        <RazorSrcFiles Condition=" '@(RazorSrcFiles)' == '' " Include="**\*.cshtml" />
        <RazorOutputFiles Include="@(RazorSrcFiles -> '$(RazorViewsCodeGenDirectory)%(RelativeDir)%(Filename)%(Extension).cs')" />
    </ItemGroup>

    <UsingTask AssemblyFile="$(RazorGeneratorMsBuildPath)" TaskName="RazorCodeGen" />
    <Target Name="PrecompileRazorFiles"
                    Inputs="@(RazorSrcFiles)"
                    Outputs="@(RazorOutputFiles)">
        <RazorCodeGen ProjectRoot="$(MsBuildProjectDirectory)"
                                    FilesToPrecompile="@(RazorSrcFiles)"
                                    CodeGenDirectory="$(RazorViewsCodeGenDirectory)"
                                    RootNamespace="$(RootNamespace)">
            <Output TaskParameter="GeneratedFiles" ItemName="FilesGenerated" />
        </RazorCodeGen>
        <ItemGroup>
          <Compile Include="@(FilesGenerated)" Condition=" '@(RazorOutputFiles)' == '' "/>
          <Compile Include="@(RazorOutputFiles)" />
        </ItemGroup>
    </Target>
</Project>

如果需要,我也可以稍后发布构建日志。

0 个答案:

没有答案