问题
I am trying to create a Microsoft Word add-in that will add and commit to a git repo every time the Word document is saved, either auto save or manual save. I have been able to get the functionality I desire when I run the program from within Visual Studio (debug mode). When I publish and install the add-in so that it runs when Word starts, I get the following error.
Now when I try to add the LibGit2Sharp NuGet packages, running in debug mode from within Visual Studio gives me this error:
and the following error details:
Name:
From: file:///C:/Users/short/OneDrive for Business/SCHOOL/JP/EZGit/EZGit/MicrosoftWordAddIn/bin/Debug/MicrosoftWordAddIn.vsto
************** Exception Text **************
System.Deployment.Application.InvalidDeploymentException: Exception reading manifest from file:///C:/Users/short/OneDrive%20for%20Business/SCHOOL/JP/EZGit/EZGit/MicrosoftWordAddIn/bin/Debug/MicrosoftWordAddIn.dll.manifest: the manifest may not be valid or the file could not be opened. ---> System.Deployment.Application.InvalidDeploymentException: Application manifest is not semantically valid. ---> System.Deployment.Application.InvalidDeploymentException: File element lib\fedora-x64\native\..\libgit2-106a5f2.so must have a relative path.
at System.Deployment.Application.Manifest.AssemblyManifest.ValidateFile(File f)
at System.Deployment.Application.Manifest.AssemblyManifest.ValidateSemanticsForApplicationRole()
--- End of inner exception stack trace ---
at System.Deployment.Application.Manifest.AssemblyManifest.ValidateSemanticsForApplicationRole()
at System.Deployment.Application.ManifestReader.FromDocument(String localPath, ManifestType manifestType, Uri sourceUri)
--- End of inner exception stack trace ---
at Microsoft.VisualStudio.Tools.Applications.Deployment.ClickOnceAddInDeploymentManager.GetManifests(TimeSpan timeout)
at Microsoft.VisualStudio.Tools.Applications.Deployment.ClickOnceAddInDeploymentManager.InstallAddIn()
I think the published solution needs the packages, but works from within Visual Studio without them. I installed them to see and then running from within Visual Studio causes an error.
I have tried changing the .csproj file to add the following
<Target Name="EnsureNetstandardFilesAreIncludedInClickOnce" BeforeTargets="_DeploymentComputeClickOnceManifestInfo">
<Message Text="Adding netstandard files to ClickOnce" />
<ItemGroup>
<PublishFile Include="@(_NETStandardLibraryNETFrameworkLib->'%(FileName)')" KeepMetadata="None">
<PublishState>Include</PublishState>
<FileType>Assembly</FileType>
</PublishFile>
</ItemGroup>
<!-- Consider using ReferenceCopyLocalPaths instead, if we are missing files -->
<Message Text="Adding nuget files to ClickOnce" />
<ItemGroup>
<PublishFile Include="@(ReferencePath->'%(FileName)')" Condition=" '%(ReferencePath.NuGetSourceType)' == 'Package' and '%(ReferencePath.NuGetIsFrameworkReference)' != 'true'" KeepMetadata="None">
<PublishState>Include</PublishState>
<FileType>Assembly</FileType>
</PublishFile>
</ItemGroup>
<Message Text="Adding Private True references to ClickOnce" />
<ItemGroup>
<PublishFile Include="@(ReferencePath->'%(FileName)')" Condition="'%(ReferencePath.Private)' == 'True'" KeepMetadata="None">
<PublishState>Include</PublishState>
<FileType>Assembly</FileType>
</PublishFile>
</ItemGroup>
</Target>
回答1:
I came across this issue as well and resolved it by removing the import statement in the csproj file at the top. The lib2git library is still referenced in the ItemGroup section
来源:https://stackoverflow.com/questions/59959944/exception-reading-manifest-from-file-microsoft-word-add-in-vsto