小编ect*_*cth的帖子

MSBuild发布dotnet核心应用程序

我的设置是:我有一个解决方案,其中包含不同的dotnet4.6应用程序(服务)。现在,我们在此解决方案中添加了一个dotnet核心项目。我可以构建和调试它,但这不会创建可执行文件。在Visual Studio中,我可以右键单击->发布...。我创建了两个配置文件(x86和x64),它们应该在/ bin / Publish / x86或/ x64中创建漂亮的二进制文件。在VS中有效。该应用程序是独立的,可以在未准备好的其他计算机上运行。

但是现在我需要将该过程移至构建服务器。我搞砸了,dotnet publish但最后我被卡住了,因为该解决方案的其他组件不是干净的dotnet核心,因此构建失败。因此,我需要坚持使用MSBuild。

当前尝试是: "C:\Program Files (x86)\Microsoft Visual Studio\2017\Professional\MSBuild\15.0\Bin\MSBuild.exe" NewProject\NewProject.csproj /p:DeployOnBuild=true /p:UsePublishProfile=true /p:PublishProfile=x64Profile

这表明它已成功完成构建,但是我看不到任何结果。如果我删除所有属性并仅调用msbuild和* .csproj,也没有任何区别。它只是在bin / Debug中以dll(而不是exe)构建新项目。

我也弄乱了p:PublishProfile="NewProject\Properties\PublishProfiles\x64Profile.pubxml"/p:PublishUrl="NewProject\bin\Publish\x64"但它没有任何改变。

我读了几篇关于SO的文章,告诉我VS不仅使用参数调用msbuild,而且还进行内部API调用。不过,我需要一个解决方案。我需要构建服务器来创建可执行文件。有没有一种方法可以触发msbuild创建该对象?

msbuild .net-core

5
推荐指数
2
解决办法
3424
查看次数

从 C# 调用 wstring C++ 方法

我正在使用 C# 代码,需要在 C++ dll 中调用此方法。

static std::wstring DecryptData(const std::wstring& strKey);
Run Code Online (Sandbox Code Playgroud)

我读过很多东西,我最好的猜测是传递一些对于两种语言都更容易阅读的东西,比如字符数组甚至字节数组,然后在 C++ 中构建 wstring,然后在 C# 中构建字符串。

有人已经这样做了吗?

编辑:

我阅读了链接主题,但没有一个答案对我有帮助:使用const没有帮助。

这就是我现在拥有的:C#

 [DllImport(DLL_PATH, CharSet = CharSet.Unicode)]
        [return: MarshalAs(UnmanagedType.LPWStr)]
        public static extern string DecryptData([MarshalAs(UnmanagedType.LPWStr)]string strKey);
Run Code Online (Sandbox Code Playgroud)

C++

extern "C" __declspec(dllexport) const std::wstring DecryptData(const std::wstring& strKey) {
    return WlanHelper::CWirelessHelper::DecryptData(strKey);
}
Run Code Online (Sandbox Code Playgroud)

这给了我一个 PInvokeStackImbalance =/

c# c++ wstring

1
推荐指数
1
解决办法
5391
查看次数

标签 统计

.net-core ×1

c# ×1

c++ ×1

msbuild ×1

wstring ×1