我有一个简单的web项目,包含bower.json,package.json和Gruntfile.js 我修改了我的.csproj文件以添加要运行的目标
npm install运行正常,但无法运行bower安装。 这就是我从日志中获得的所有内容
node_modules\.bin\bower cache clean
node_modules\.bin\bower install
C:\a\src\TestProj\TestProj\TestProj.csproj(137,5): error MSB3073: The command ".\node_modules\.bin\bower install" exited with code 1.
以下是我在csproj definitio中所做的事情
<Target Name="BeforeBuild">
<Exec Command="npm cache clean" />
<Exec Command="npm install" />
<Exec Command="node_modules\.bin\bower cache clean" />
<Exec Command="node_modules\.bin\bower install" />
</Target>
这是我的bower.json
"name": "TestProj",
"version": "0.0.1",
"description": "",
"main": "index.html",
"moduleType": [
"amd"
],
"authors": [
"Sujesh Arukil"
],
"license": "MIT",
"private": true,
"ignore": [
"**/.*",
"node_modules",
"bower_components",
"test",
"tests"
],
"devDependencies": {
"knockoutjs": "~3.2.0"
}
答案 0 :(得分:2)
我能够通过在.csproj文件中注释掉bower install命令来解决这个问题
private void Button_Click(object sender, RoutedEventArgs e)
{
if (_window == null)
{
Thread thread = new Thread(ShowWindow);
thread.IsBackground = false;
thread.SetApartmentState(ApartmentState.STA);
thread.Start();
}
else
{
_window.Dispatcher.Invoke(_window.Close);
Window w = _window;
_window = null;
new Thread(() =>
{
Thread.Sleep(100);
w.Dispatcher.InvokeShutdown();
w = null;
}).Start();
}
}
private Window CreateWindow()
{
Window w = new Window();
w.AllowsTransparency = true;
//w.Content = Some magic Animated Circle...
w.Background = new SolidColorBrush(Color.FromArgb(70, 0, 0, 0));
w.WindowStartupLocation = WindowStartupLocation.Manual;
w.WindowStyle = WindowStyle.None;
return w;
}
public void ShowWindow()
{
Thread uiThread = new Thread(() =>
{
_window = CreateWindow();
_window.Show();
System.Windows.Threading.Dispatcher.Run();
});
uiThread.SetApartmentState(ApartmentState.STA);
uiThread.IsBackground = true;
uiThread.Start();
}
答案 1 :(得分:1)
答案 2 :(得分:0)
首先,启用诊断日志记录。
然后修改你的目标:
<Target Name="BeforeBuild">
<Exec Command="npm cache clean" />
<Exec Command="npm install" />
<Message Condition="!EXISTS('node_modules\.bin\bower')" Text="bower does not exist" Importance="high" />
<Exec Command="node_modules\.bin\bower cache clean" />
<Exec Command="node_modules\.bin\bower install" />
</Target>
答案 3 :(得分:0)
您应该能够下载其中可能包含更多详细信息的其他MSBuild日志文件。如果您查看以前失败的构建,请单击&#34;查看日志&#34;链接在顶部,然后查看详细信息,您应该看到日志文件的链接几行超过您的错误消息。
如果因为git不可用而得到错误,我不得不猜测我的头脑。
答案 4 :(得分:0)
通过删除.csproj文件中的以下代码为我工作。
<Target Name="PrepublishScript" BeforeTargets="PrepareForPublish">
<Exec Command="bower install" />
<Exec Command="dotnet bundle" />
但是它确实导致了一些带有重复方法名称的打字稿问题,将以下代码添加到tsconfig.json文件中
"exclude": [
"obj"
]