【问题标题】:Notepad++ plugin build error VS 2013Notepad++ 插件构建错误 VS 2013
【发布时间】:2014-05-06 14:29:34
【问题描述】:

我已经从http://sourceforge.net/projects/sourcecookifier/files/other%20plugins/NppPlugin.NET.v0.5.zip/download下载了用于 .NET 的 notepad++ 插件

当我尝试构建我的解决方案时,它给出了以下错误:

The "DllExportTask" task failed unexpectedly.
System.ArgumentException: The path is not of a legal form.
at System.IO.Path.NormalizePath(String path, Boolean fullCheck, Int32 maxPathLength,Boolean expandShortPaths)
at System.IO.Path.GetFullPathInternal(String path)
at System.IO.Path.GetFullPath(String path)
at NppPlugin.DllExport.MSBuild.DllExportTask.TrySearchToolPath(String toolPath, String toolFilename, String& value)
at NppPlugin.DllExport.MSBuild.DllExportTask.ValidateInputValues()
at NppPlugin.DllExport.MSBuild.DllExportTask.Execute()
at Microsoft.Build.BackEnd.TaskExecutionHost.Microsoft.Build.BackEnd.ITaskExecutionHost.Execute()
at Microsoft.Build.BackEnd.TaskBuilder.<ExecuteInstantiatedTask>d__20.MoveNext()    NppManagedPluginDemo.VS2010

从代码分析可以看出,无效路径位于NppPlugin.DllExport.targets(4,5),文件内容为:

<Project xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
  <UsingTask TaskName="NppPlugin.DllExport.MSBuild.DllExportTask" AssemblyFile="NppPlugin.DllExport.MSBuild.dll"/>
  <Target Name="AfterBuild" DependsOnTargets="GetFrameworkPaths">
     <DllExportTask Platform="$(Platform)"
               PlatformTarget="$(PlatformTarget)"
               CpuType="$(CpuType)"
               EmitDebugSymbols="$(DebugSymbols)"
               DllExportAttributeAssemblyName="$(DllExportAttributeAssemblyName)"
               DllExportAttributeFullName="$(DllExportAttributeFullName)"
               Timeout="$(DllExportTimeout)"
               KeyContainer="$(KeyContainerName)$(AssemblyKeyContainerName)"
               KeyFile="$(KeyOriginatorFile)"
               ProjectDirectory="$(MSBuildProjectDirectory)"
               InputFileName="$(TargetPath)"
               FrameworkPath="$(TargetedFrameworkDir);$(TargetFrameworkDirectory)"
               LibToolPath="$(DevEnvDir)\..\..\VC\bin"
               LibToolDllPath="$(DevEnvDir)"
               SdkPath="$(FrameworkSDKDir)"/>
  </Target>
</Project>  

看来 $(Platform) 宏是无效的。如何修复此错误以构建我的解决方案?我正在使用 VS 2013 express for desktop 来构建我的解决方案。

【问题讨论】:

  • "$(Platform) 是当前项目平台的名称(例如,"Win32")。"您的项目是否设置了构建平台?
  • 我遇到同样的构建失败,但我认为这是因为$(TargetedFrameworkDir); 包含双反斜杠(即\\ ),构建日志显示Task Parameter:FrameworkPath=C:\Windows\Microsoft.NET\Framework\\v4.5;C:\Program Files (x86)\Reference Assemblies\Microsoft\Framework\.NETFramework\v4.5\;;;C:\Program Files (x86)\Reference Assemblies\Microsoft\Framework\.NETFramework\v4.5\Facades\ (TaskId:44)

标签: c# .net notepad++


【解决方案1】:

我刚刚遇到了同样的问题,但我找不到任何具体的答案。这是我所做的:

文件 {Project Dir}/DllExport/NppPlugin.DllExport.targets 的内容将是:

<Project
  xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
  <UsingTask TaskName="NppPlugin.DllExport.MSBuild.DllExportTask"
             AssemblyFile="NppPlugin.DllExport.MSBuild.dll"/>
  <Target Name="AfterBuild"
          DependsOnTargets="GetFrameworkPaths"
          >
    <DllExportTask Platform="$(Platform)"
                   PlatformTarget="$(PlatformTarget)"
                   CpuType="$(CpuType)"
                   EmitDebugSymbols="$(DebugSymbols)"
                   DllExportAttributeAssemblyName="$(DllExportAttributeAssemblyName)"
                   DllExportAttributeFullName="$(DllExportAttributeFullName)"
                   Timeout="$(DllExportTimeout)"
                   KeyContainer="$(KeyContainerName)$(AssemblyKeyContainerName)"
                   KeyFile="$(KeyOriginatorFile)"
                   ProjectDirectory="$(MSBuildProjectDirectory)"
                   InputFileName="$(TargetPath)"
                   FrameworkPath="$(TargetedFrameworkDir);$(TargetFrameworkDirectory)"
                   LibToolPath="$(DevEnvDir)\..\..\VC\bin"
                   LibToolDllPath="$(DevEnvDir)"
                   SdkPath="$(FrameworkSDKDir)"/>
  </Target>
</Project>

令人不安的是:

SdkPath="$(FrameworkSDKDir)"/>

在较新版本的 Visual Studio 中应更改为以下内容:

SdkPath="$(SDK40ToolsPath)"/>

导致文件:

<Project
  xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
  <UsingTask TaskName="NppPlugin.DllExport.MSBuild.DllExportTask"
             AssemblyFile="NppPlugin.DllExport.MSBuild.dll"/>
  <Target Name="AfterBuild"
          DependsOnTargets="GetFrameworkPaths"
          >
    <DllExportTask Platform="$(Platform)"
                   PlatformTarget="$(PlatformTarget)"
                   CpuType="$(CpuType)"
                   EmitDebugSymbols="$(DebugSymbols)"
                   DllExportAttributeAssemblyName="$(DllExportAttributeAssemblyName)"
                   DllExportAttributeFullName="$(DllExportAttributeFullName)"
                   Timeout="$(DllExportTimeout)"
                   KeyContainer="$(KeyContainerName)$(AssemblyKeyContainerName)"
                   KeyFile="$(KeyOriginatorFile)"
                   ProjectDirectory="$(MSBuildProjectDirectory)"
                   InputFileName="$(TargetPath)"
                   FrameworkPath="$(TargetedFrameworkDir);$(TargetFrameworkDirectory)"
                   LibToolPath="$(DevEnvDir)\..\..\VC\bin"
                   LibToolDllPath="$(DevEnvDir)"
                   SdkPath="$(SDK40ToolsPath)"/>
  </Target>
</Project>

这将修复构建错误“系统找不到指定的文件”以及“此 ANSI 插件与您的 Unicode Notepad++ 不兼容”

【讨论】:

    【解决方案2】:

    我遇到了同样的问题,MS Connect 上的以下项目对我有用:https://connect.microsoft.com/VisualStudio/feedback/details/811986/-frameworksdkdir-value-in-vs-macros-post-build-event-references-invalid-path

    最好使用 $(SDK40ToolsPath) 属性来获取 .NET SDK 二进制文件路径,而不是使用 $(FrameworkSDKDir) 手动构建路径强>属性。使用“$(SDK40ToolsPath)sgen.exe”应该可以在 Visual Studio 2013 及更早版本中使用。

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2017-08-22
      • 2014-03-12
      • 1970-01-01
      • 2017-02-07
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多